概述
本文Python绘图加中文图例的方法总结,基于matplotlib库的pyplot,即
import matplotlib.pyplot as plt
中文
需要在程序定义前输入:
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] =False
加入图注
使用plt.legend()
函数加入图例,该函数会按照顺序给图线添加图例,例如:
plt.legend(labels=['对比实验','编队搜索'])
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/5ac14a763a204988b99e07808d6a2d62.png#pic_center)