pyplot绘图常用代码

https://zhuanlan.zhihu.com/p/366489354

import matplotlib.pyplot as plt

x = [i for i in range(10)]
y = [random.random() for _ in range(10)]
y1 = [random.random() for _ in range(10)]
y2 = [random.random() for _ in range(10)]

plt.title('Result Analysis')
plt.plot(x, y, color='green', label='training accuracy')
plt.plot(x, y1, color='red', label='testing accuracy')
plt.plot(x, y2, color='skyblue', label='PN distance')
plt.legend(fontsize=10, markerscale=5)  # 显示图例,分别设置图例的字体大小和标记大小

plt.xlabel('iteration times')
plt.ylabel('rate')
plt.show()
posted @ 2023-02-02 14:46  笨笨和呆呆  阅读(26)  评论(0)    收藏  举报