LoginSignup
3
3

More than 3 years have passed since last update.

[mac] matplotlib最短で日本語対応

Last updated at Posted at 2018-08-15

1.日本語対応フォントをダウンロード

IPAフォント ダウンロードページ
今回はIPAゴシックを用いる

2.ダウンロードしたttfファイルをダブルクリックしてfont bookからインストール

3.~/.matplotlib/fontList.jsonを削除(フォントのキャッシュ削除)

4.matplotlibインポート後にフォント変更

cf.py
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'IPAPGothic' #全体のフォントを設定

5.decodeしてプロット

cf.py
cf=[38.581,45.605,53.476,61.858,61.740,68.210,67.691,74.289,89.813,117.726,143.940,151.615,159.194,174.699]
years=range(2004,2018)
plt.plot(years,cf)
plt.legend(['対外純投資'.decode('utf-8')])
plt.show()

ダウンロード.png

参考

matplotlib と Seaborn の軸の日本語設定
3分でmatplotlibを日本語対応させる

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3