how to let matplotlib show foreign language without font_manager

Viewed 663

I'm using matplotlib drawing a scatter chart, I have labels in multiple languages (Chinese, Arabic, Korean...). Now, my chart shows like this: enter image description here

Is there anyway to show this foreign language labels with only matplotlib.pyplot, sys and os library? Thank you.

1 Answers

As far as I know from my deliberate search on a similar problem, the only solution I came up with is to specify the missing font packs, download them from google fonts, and use them in matplotlib with the following code. However, I still can not use multiple languages. My solution only solves the problem with one font family. The code below takes the ttf font family from the directory you specified and uses it in the part of the plot you wish by "fontproperties=fprop" argument, here in yticklabels.

from matplotlib import font_manager as fm
fprop = fm.FontProperties(fname='/.../ms-pgothic_bigfontsite.com.ttf')
ax.set_yticklabels(list(hashtag_ordered_keys)[::-1],fontproperties=fprop)
Related