matplotlib中国語フォントを使用

1146 ワード

matplotlib自体は中国語をサポートしていません(utf-8はダメですか)が、一定の方法で解決できます
from matplotlib import font_manager

# fname              
my_font = font_manager.FontProperties(fname=r"C:\Windows\Fonts\msyhl.ttc") 
#         fontproperties  
plt.title("    ", fontproperties=my_font)

ただしplt.legendではpropが必要です
plt.legend(prop=my_font)