第一步
找到matplotlib 配置文件:
import matplotlib
print(matplotlib.matplotlib_fname())
第二步
然后将matplotlibrc
文件中的
#font.family: sans-serif
去掉注释,修改为
font.family: Microsoft YaHei
第三步
下载字体:msyh.ttf (微软雅黑)
放在matplotlib
字体文件夹下:
D:\Program Files\Python36\Lib\site-packages\matplotlib\mpl-data\fonts\ttf
第四步
删除.matplotlib/cache
里面的两个缓存字体文件C:\Users\你的用户名\.matplotlib
tex.cache
fontList.json
在服务器中地址是
./root/.cache/matplotlib/tex.cache
第五步
重启Python