1、 下載字體python
SimHei.ttflinux
複製到linux字體庫中字體
sudo cp ~/SimHei.ttf /usr/share/fonts/SimHei.ttf
2、查看matplotlib配置spa
In [1]: import matplotlib
In [2]: matplotlib.matplotlib_fname() Out[2]: '/home/python/.virtualenvs/ai/local/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc'
3、修改配置文件code
sudo vi /home/python/.virtualenvs/ai/local/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc
添加這三行代碼便可blog
font.family : sans-serif font.sans-serif : SimHei # SimHei 也能夠寫成小寫的simhei axes.unicode_minus : False
4、刪除matplotlib緩衝unicode
# 直接刪除就好cd ~/.cache/matplotlib rm -r *