彻底解决Matplotlib显示中文问题

1. 查看matplotlib配置文件

import matplotlib
print(matplotlib.matplotlib_fname())

Out:{your-matplotlib-installed-path}/mpl-data/matplotlibrc

2. 下载simhei字体
    点击下载simhei字体

3. 复制字体文件
    将下载的字体文件复制到第一步显示的目录中的相对路径

{your-matplotlib-installed-path}/mpl-data/fonts/ttf

4. 修改配置文件(matplotlibrc)中使用的字体

font.family        : sans-serif
font.sans-serif    : SimHei
axes.unicode_minus : False

5. 清除用户目录下的.cache/matplotlib文件夹

rm -rf ~/.cache/matplotlib

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章