Help us understand the problem. What is going on with this article?

matplotlibで日本語

More than 5 years have passed since last update.

matplotlib.pyplotでたま~に日本語を使う必要があり,そのたびに
あれ?fontpropertiesだっけ?propだっけ?property?
となるので整理してみたら,凡例だけpropで,あとはfontpropertiesなのですね.
(propertyなんて無いし…)

ご参考まで.

fontproperties.png

japanese_in_matplotlib.py
# -*- 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()
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした