使用matplotlib绘制折线图
示例1
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams["font.sans-serif"]=["SimHei"]
plt.rcParams["axes.unicode_minus"]=False
font = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 15,
}
x = np.arange(1,9)
y1 = [0.7, 0.7, 0.6, 0.5, 0.5, 0.4, 0.4, 0.4]
y2 = [0.8, 0.7, 0.7, 0.6, 0.5, 0.5, 0.4, 0.4]
y3 = [0.6, 0.6, 0.5, 0.5, 0.4, 0.4, 0.4, 0.3]
y4 = [0.8, 0.8, 0.7, 0.6, 0.5, 0.5, 0.4, 0.4]
plt.plot(x, y1, color='m', marker='.', markersize=10, linestyle='--', linewidth=2.0, clip_on=False)
plt.plot(x, y2, color='g', marker='.',markersize=10, linestyle='-.', linewidth=2.0, clip_on=False)
plt.plot(x, y3, color='c', marker='.', markersize=10, linestyle=':', linewidth=2.0, clip_on=False)
plt.plot(x, y4, color='r', marker='.',markersize=10, linestyle='-', linewidth=2.0, clip_on=False)
plt.xticks(np.arange(1, 8.1, 1), fontproperties='Times New Roman', size = 13)
plt.yticks(np.arange(0.3, 1.1, 0.1), fontproperties='Times New Roman', size = 13)
plt.xlim((1, 8))
plt.xlabel("Number of pictures", font)
plt.ylabel("Average RD", font)
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 14,
}
plt.legend(['Euclidean', 'Manhattan', "Chebyshev", "Ours"], prop = font1, frameon=False, loc="upper right")
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.show()
示例2
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams["font.sans-serif"]=["SimHei"]
plt.rcParams["axes.unicode_minus"]=False
font = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 15,
}
x = ['dinosaur', 'build', 'plane', 'car','cat', 'flower', 'train', 'tree', 'landscape', 'wolf']
y1 = [0.9,0.3,0.4,0.4,0.9,0.8,0.6,0.7,0.4,0.8]
y2 = [1,0.3,0.3,0.7,1,0.8,0.5,0.7,0.8,0.8]
plt.plot(x, y1, color='#4F94CD', marker='.', markersize=10, linestyle='--', linewidth=2.0, clip_on=False, label='LBP')
plt.plot(x, y2, color='r', marker='.',markersize=10, linestyle='-', linewidth=2.0, clip_on=False, label='IU-LBP')
plt.ylabel("Average RD", font)
plt.xticks(fontproperties='Times New Roman', size = 13)
plt.yticks(np.arange(0.3, 1.1, 0.1), fontproperties='Times New Roman', size = 13)
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 14,
}
plt.legend(prop = font1, frameon=False, loc="upper right")
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.show()