python matplot画图支持中文

1、下载simhei.ttf

 

 2、放在python路径下

D:\Soft\Python3.8\Lib\site-packages\matplotlib\mpl-data\fonts\ttf

 

3、代码增加

import matplotlib as mpl

# 中文支持
mpl.rcParams['font.sans-serif'] = ['SimHei']    # 指定默认字体:解决plot不能显示中文问题
mpl.rcParams['axes.unicode_minus'] = False           # 解决保存图像是负号'-'显示为方块的问题

 

posted @ 2020-04-28 09:51  朱小勇  阅读(839)  评论(0编辑  收藏  举报