作者ides13 (juso)
看板Python
標題Re: [問題] win10 matplotlib 中文無法顯示
時間Mon Jun 26 16:27:31 2017
http://tinyurl.com/ydyc8u3s
可以用以下指令查看可以使用的字型
import matplotlib.font_manager
matplotlib.font_manager.findSystemFonts(fontpaths=None)
然後用以下指令,進行字型的全域設定
plt.rcParams["font.family"] = "可使用字型名稱"
另外,使用FontProperties,可以透過路徑來選取字型。
import matplotlib.font_manager
legend = ax.legend()
font = font_manager.FontProperties(fname='C:\\Fonts\\maisfontes-osaka.ttf')
for text in legend.texts:
text.set_font_properties(font)
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.133.32.131
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1498465656.A.099.html
※ 編輯: ides13 (220.133.32.131), 06/27/2017 13:04:31
推 dirls: 搞了好久,才發現win10的字型是ttc,matplotlib不認得。 06/29 23:20
→ dirls: 把副檔名換成ttf後,要把~/.matplotlib 暫存檔刪掉 06/29 23:22
→ dirls: 新的設定才會生效。 感謝你~~~~ 06/29 23:23