作者peter308 (pete)
看板Python
标题[问题] matplotlib 下怎麽使用times new roman?
时间Tue Mar 15 16:28:47 2022
我的matplotlib版本是 3.5.1
我在画图的时候
想把字型设定成 Times new Roman
但是一直有错误讯息
findfont: Font family ['Times New Roman'] not found. Falling back to DejaVu
Sans.
有人知道要怎麽在matplotlib下去安装Times New Roman字型吗?
这问题我google搜寻了一阵子
似乎一直找不到解答
所以才来版上询问一下版友意见
万分感谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.117.32.17 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1647332933.A.880.html
1F:推 karco: plt.rcParams["font.family"] = "Times New Roman" 03/15 16:37
2F:→ karco: 你是这样设定吗? 03/15 16:37
3F:推 lycantrope: 先移除matplotlib font cache试试看吧 03/15 16:50
4F:→ lycantrope: import matplotlib as mpl; mpl.get_cachedir() 03/15 16:51
5F:→ lycantrope: 把找到的cache资料夹删掉,试看看 03/15 16:52
6F:→ peter308: 找到解决方法了 03/15 17:08
7F:→ peter308: import matplotlib.pyplot as plt 03/15 17:08
8F:→ peter308: plt.rcParams["font.family"] = "serif" 03/15 17:08
9F:→ peter308: plt.rcParams['font.serif'] = ['Times New Roman'] + p 03/15 17:09
10F:→ peter308: plt.rcParams['font.serif'] 03/15 17:09
11F:推 daniel08888: 推分享精神 03/18 20:35