徹底解決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

 

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