You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use Chinese text in my plot. There are some pre-installed font on the system which support Chinese (using fc-list :lang=zh), for example "WenQuanYi Zen Hei". But I find that these fonts can not be found by matplotlib. I checked some of the code of font_manager. I find that font_manger seems intentionally avoid finding font files in ttc extensions.
In order to use these font, I have to explicitly give the path of the font, like the following example code:
import matplotlib.pyplot as plt
import matplotlib.font_manager as mfm
ch_font = mfm.FontProperties(fname="/usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc")
plt.annotate(xy=(0.5, 0.5), s=u'测试', xycoords='axes fraction', fontproperties=ch_font)
plt.show()
What is the reason behind this ?
Matplotlib version
Operating System: CentOS 7.2
Matplotlib Version: 2.0.1
Python Version: 3.6
The text was updated successfully, but these errors were encountered:
I am trying to use Chinese text in my plot. There are some pre-installed font on the system which support Chinese (using
fc-list :lang=zh
), for example "WenQuanYi Zen Hei". But I find that these fonts can not be found by matplotlib. I checked some of the code of font_manager. I find that font_manger seems intentionally avoid finding font files in ttc extensions.In order to use these font, I have to explicitly give the path of the font, like the following example code:
What is the reason behind this ?
Matplotlib version
The text was updated successfully, but these errors were encountered: