[mac] matplotlib最短で日本語対応
3491 ワード
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()
参考
Author And Source
この問題について([mac] matplotlib最短で日本語対応), 我々は、より多くの情報をここで見つけました https://qiita.com/lilpacy/items/de5f31984f6249d32a70著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .