作者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/m.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