I am new to matplotlib and trying to plot a 2D/3D chart with non-ASCII texts in it, I am able to use show() to plot on screen:
plt.text(X, Y, str(text[i].decode('utf-8')) )
plt.show()
However when I try to save the figure to a file with
savefig(), all texts become little squares []
I am sure it is a font related problem but I can't see to figure out how to fix this.
I am on a Mac OSX 10.10.5, if that matters.
finally solved it by using:
fontpath = '/Library/Fonts/华文细黑.ttf'
properties = font_manager.FontProperties(fname=fontpath)
matplotlib.rcParams['font.family'] = properties.get_name()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With