legend 传奇、图例。
plt.legend()的作用:
在plt.plot() 定义后plt.legend() 会显示该 label 的内容,否则会报error: No handles with labels found to put in legend.
plt.plot(result_price, color = 'red', label = 'Training Loss')
legend作用位置:下图红圈处。

本文介绍了matplotlib库中plt.legend()函数的作用,它用于在图表上添加图例。只有当plt.plot()等函数指定了label参数后,plt.legend()才会显示对应的内容。图例通常位于图表的右下角,用于清晰标识不同数据系列。了解这一功能对于提升数据可视化的效果至关重要。
legend 传奇、图例。
plt.legend()的作用:
在plt.plot() 定义后plt.legend() 会显示该 label 的内容,否则会报error: No handles with labels found to put in legend.
plt.plot(result_price, color = 'red', label = 'Training Loss')
legend作用位置:下图红圈处。


被折叠的 条评论
为什么被折叠?