matplotlib中本身是不支持中文的(utf-8都不行吗),但是我们可以通过一定的方法进行解决
from matplotlib import font_manager
# fname 指定为系统中支持中文的字体
my_font = font_manager.FontProperties(fname=r"C:\Windows\Fonts\msyhl.ttc")
# 调用的时候指定 fontproperties即可
plt.title("图形图像", fontproperties=my_font)
但是在plt.legend
中需要使用prop
plt.legend(prop=my_font)