You need to pick an otf font that actually supports Chinese but other than that, it's already working...
from matplotlib.font_manager import FontProperties
from matplotlib import pyplot as plt
plt.title(
"黑體",
fontproperties=FontProperties(
fname="/usr/share/fonts/adobe-source-han-sans-tw/SourceHanSansTW-Regular.otf"))
plt.show()
See #9787 for ttc support and #10249 for font selection issues.
We can make the experience better by putting #9175 back in with a slightly more verbose error message (it was reverted in #11615 due to other issues).
I'll leave this closed, as #8765 already tracks the same issue.
Activity
anntzer commented on Oct 23, 2018
You need to pick an otf font that actually supports Chinese but other than that, it's already working...
from matplotlib.font_manager import FontProperties from matplotlib import pyplot as plt plt.title( "黑體", fontproperties=FontProperties( fname="/usr/share/fonts/adobe-source-han-sans-tw/SourceHanSansTW-Regular.otf")) plt.show()See #9787 for ttc support and #10249 for font selection issues.
anntzer commented on Oct 23, 2018
Actually that's essentially documented at https://matplotlib.org/tutorials/text/text_props.html#text-with-non-latin-glyphs. Closing, but feel free to ping with more questions.
liam-nirvana commented on Oct 24, 2018
tacaswell commented on Oct 24, 2018
@liam-nirvana Glad you got this sorted! Fonts are surprisingly hard....
fighting41love commented on Nov 6, 2018
Same problem. It's really terrible experience to modify the font. Many people fix the problem for hours.....I spent 2 hours on it. Failed.
anntzer commented on Nov 6, 2018
We can make the experience better by putting #9175 back in with a slightly more verbose error message (it was reverted in #11615 due to other issues).
I'll leave this closed, as #8765 already tracks the same issue.