Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 matplotlib 在我的图例中添加字幕。有没有其他方法可以做到这一点?
谢谢,
最好的,
如果您想要绘制每条线的图例,您可以这样做:
plt.plot(x, y1, label='Line One') plt.plot(x, y2, label='Line Two') plt.legend(loc='best')
每个label关键字参数都提供了行的标签,并且该legend()命令创建了一个内部带有图例的框。可选loc参数(位置)试图阻止将图例框放置在线条上。
label
legend()
loc