import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
def lineChart6():
"""l验证结果"""
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False # 表示图中显示汉字
x = np.linspace(0, 100, 10)
y1 = [0.755, 0.87, 0.89, 0.960, 0.969, 0.973, 0.976, 0.980, 0.989, 0.988]
y2 = [0.231, 0.201, 0.147, 0.131, 0.121, 0.101, 0.034, 0.025, 0.010, 0.013]
plt.figure()
plt.xlim(0, 100)
plt.ylim(0, 1)
l1, = plt.plot(x, y1, color='black', linestyle='--', label=u"准确率", )
l2, = plt.plot(x, y2, color='black', linestyle='-', label=u"损失曲线", )
plt.legend(handles=[l1,l2], loc='best') #
plt.xlabel("训练轮数") # X轴文本
plt.ylabel("训练结果")
plt.xticks([0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
plt.yticks([0,0.1,0.2,0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
plt.show()
def lineChart7():
"""l验证结果"""
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False # 表示图中显示汉字
x = np.linspace(0, 100, 10)
y1 = [0.69, 0.87, 0.89, 0.91, 0.93, 0.93, 0.944, 0.951, 0.952, 0.952]
y2 = [0.585, 0.312, 0.289, 0.213, 0.201, 0.200, 0.189, 0.172, 0.171, 0.170]
plt.figure()
plt.xlim(0, 100)
plt.ylim(0, 1)
l1, = plt.plot(x, y1, color='black', linestyle='--', label=u"准确率", )
l2, = plt.plot(x, y2, color='black', linestyle='-', label=u"损失曲线", )
plt.legend(handles=[l1,l2], loc='best') #
plt.xlabel("训练轮数") # X轴文本
plt.ylabel("验证结果")
plt.xticks([0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
plt.yticks([0,0.1,0.2,0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
plt.show()
def lineChart1():
"""l验证结果"""
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False # 表示图中显示汉字
x = np.linspace(0, 1, 20)
y1 = [0, 0.4,0.8,0.87, 0.929,0.951, 0.971,0.973, 0.974,0.976, 0.978, 0.9795,0.981,0.985, 0.989,0.990, 0.991,0.9915,0.992,0.9924]
y2 = [0, 0.2, 0.4, 0.48, 0.51, 0.551, 0.63, 0.78, 0.8, 0.82, 0.89, 0.97, 0.98, 0.98, 0.982, 0.983, 0.984,
0.985, 0.986, 0.987]
y3 = [0, 0.06, 0.1, 0.15, 0.2, 0.26, 0.3, 0.36, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.76, 0.8,
0.84, 0.9, 0.99]
plt.figure()
plt.xlim(0, 1)
plt.ylim(0, 1)
l1, = plt.plot(x, y1, color='black', linestyle='--', label=u"本文算法", )
l2, = plt.plot(x, y2, color='black', linestyle='-', label=u"WV-CNN", )
l3, = plt.plot(x, y3, color='black', linestyle=':', label=u"WV-Cosine", )
plt.legend(handles=[l1,l2,l3], loc='best') #
plt.xlabel("假正率") # X轴文本
plt.ylabel("真正率")
plt.xticks([0,0.1,0.2,0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
plt.yticks([0,0.1,0.2,0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
plt.show()
def barGraph5():
"""
两个柱状图
"""
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False # 表示图中显示汉字
x = np.arange(8) # 生成0--4五个数
y = [0.96, 0.99, 0.98, 0.996, 0.995, 0.988, 0.965, 0.968] # 第一个柱子高度
y1 = [0.86, 0.95, 0.9, 0.87, 0.99, 0.97, 0.95, 0.95] # 第二个柱子高度
y3 = [0.93, 0.91, 0.95, 0.85, 0.95, 0.93, 0.87, 0.964]
bar_width = 0.2 # 柱子宽度
tick_label = ["A", "B", "C", "D", "E", "F", "G", "H"] # X轴要显示的刻度
bar1 = plt.bar(x, y, bar_width, align="center", color="black", label="本算法", alpha=0.5) # 生成一个柱状图
bar2 = plt.bar(x + bar_width, y1, bar_width, color="white", align="center", label="WV-CNN", alpha=0.5,edgecolor='black') # 生成第二个柱状图
bar3 = plt.bar(x + bar_width * 2, y3, bar_width, align="center", label="WV-Cosine", alpha=0.5, hatch = "//",color='white', edgecolor='black')
plt.xlabel("样本组") # X轴文本
plt.ylabel("准确度") # Y轴文本
plt.ylim(0, 1.2)
plt.yticks([0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
plt.xticks(x + 2 * bar_width / 2, tick_label) # X轴文本显示的位置
plt.legend(handles=[bar1, bar2, bar3], loc='best') # 图例
plt.show()
barGraph5()