Created
March 16, 2015 08:53
-
-
Save canard0328/c9d6010ef8b2019a4825 to your computer and use it in GitHub Desktop.
matplotlibで日本語 ref: http://qiita.com/canard0328/items/a859bffc9c9e11368f37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import matplotlib.pyplot as plt | |
from matplotlib.font_manager import FontProperties | |
fp = FontProperties(fname=r'C:\WINDOWS\Fonts\YuGothic.ttf', size=14) | |
plt.bar([1, 2], [5, 10], 0.25) | |
plt.bar([1.25, 2.25], [4, 8], 0.25, color='darkorange') | |
plt.xlim((0.75, 2.75)) | |
plt.ylim((0, 12)) | |
plt.ylabel(u'軸ラベルはfontproperties=fp', fontproperties=fp) | |
plt.xticks([1.25, 2.25], [u'目盛りは', 'fontproperties=fp'], fontproperties=fp) | |
plt.title(u'タイトルはfontproperties=fp', fontproperties=fp) | |
plt.text(2.125, 10, u'テキストは\nfontproperties=fp', fontproperties=fp, | |
ha='center') | |
plt.annotate(u'アノテーションは\nfontproperties=fp', xy=(1.125, 5), xytext=(1.3, 8), | |
fontproperties=fp, arrowprops=dict(facecolor='k', shrink=0.05)) | |
plt.legend([u'凡例は', 'prop=fp'], prop=fp, loc='upper left') | |
# plt.show() | |
plt.savefig('fontproperties.png', bbox_inches='tight') | |
plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment