標籤:

直接拿過來用的python代碼

畫 x 軸間隔不均勻的折線圖

import numpy as np
import matplotlib.pyplot as plt
nums = [1,5,10,50,100,200]
x = range(len(nums))
y = [62.32,88.04,95.31,97.62,98.59,99.27]
plt.figure()
xticks = np.linspace(0,200,6)
plt.xticks(x, nums, rotation=-0)
plt.plot(xticks, y, marker=o, label=OA)
plt.xlim(-2,202)
plt.ylim(60,100)
xticks = np.linspace(0,200,6)
plt.xticks(xticks) # 劃重點
yticks = np.linspace(60,100,5)
plt.yticks(yticks) # 劃重點
plt.xlabel(OA with different train number)
plt.ylabel(overall accuracy(OA) %)
plt.title(different number with different methods)
plt.legend(loc=0)
# plt.show()
plt.savefig(draw_line.png)


推薦閱讀:

TAG:Python |