首页 > 其他分享 >如何添加matplotlib中的字体(以Times New Roman字体为例)

如何添加matplotlib中的字体(以Times New Roman字体为例)

时间:2022-10-22 17:45:23浏览次数:80  
标签:为例 matplotlib Times Roman 字体 New ttf

参考链接:(14条消息) python绘图之Times New Roman字体以及Helvetica字体_燕策西的博客-CSDN博客_python画图字体如何设置新罗马

 

下面以如何添加Times New Roman字体为例:

  • 获取目标文件——times.ttf(笔者就在自己的windows系统中用Everything搜索得到了此文件);
  • 将times.ttf文件复制到当前python环境下的site-packages/matplotlib/mpl-data/fonts/ttf/文件夹中;
  • 获取matplotlib的缓冲目录:
import matplotlib
print(matplotlib.get_cachedir())
  • 删除matplotlib的缓冲目录:
rm -rf [cachedir]
  • 再次import matplotlib时即可使用Times New Roman字体;

标签:为例,matplotlib,Times,Roman,字体,New,ttf
From: https://www.cnblogs.com/lucifer1997/p/16290100.html

相关文章