matplotlib包图例出现中文乱码问题

1、下载中文包

https://github.com/StellarCN/scp_zh/blob/master/fonts/SimHei.ttf

2、查找matplotlib所在的文件路径

python3

然后在python3中输入

>>>import matplotlib

>>>matplotlib.matplotlib_fname()

文件路径

>>>exit()

3、将SimHei.ttf文件复制到mpl-data/fonts/ttf/文件夹下

4、更改matplotlibrc文件

font.family : sans-serif

font.sans-serif : SimHei

axes.unicode_minus : False

5、重新加载字体

python3

>>>from matplotlib.font_manager import _rebuild

>>>_rebuild()

 

posted @ 2020-10-02 15:11  stacso  阅读(164)  评论(0编辑  收藏  举报