Matplotlib Times New Roman 字体设置

matplotlib设置字体报错:

findfont: Font family ['Times New Roman'] not found. Falling back to DejaVu Sans.

解决方案:
https://zhuanlan.zhihu.com/p/509574840
在这里插入图片描述
上传字体文件到/usr/share/fonts文件夹:

mkdir /usr/share/fonts
mv *.TTF /usr/share/fonts

删除matplotlib缓存:

rm ~/.cache/matplotlib/ -rf

matplotlib字体设置代码:

plt.rc('font',family='Times New Roman', size=15)
Logo

鸿蒙生态一站式服务平台。

更多推荐