在终端python 的环境下,查看字体路径
1 import matplotlib
2 print(matplotlib.matplotlib_fname())
下载simhei.ttf ,放到指定目录下,例如我的目录为: /home/muli/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/fonts/ttf
在home目录下,执行 ctrl + h ,打开隐藏目录, 删除 ~/.cache/matplotlib的缓冲目录
修改/home/muli/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data 里面的matplotlibrc文件,修改如下:
1 font.family : sans-serif
2 font.sans-serif : SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
3 axes.unicode_minus,将True改为False,作用就是解决负号’-'显示为方块的问题
如果没有效果,可能需要开机重启
参考博客 https://blog.csdn.net/mr_muli/article/details/89485619