Skip to content

Instantly share code, notes, and snippets.

@messefor
Last active December 4, 2016 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save messefor/e216d02b2d38dededf632a53cfa0f90c to your computer and use it in GitHub Desktop.
Save messefor/e216d02b2d38dededf632a53cfa0f90c to your computer and use it in GitHub Desktop.
matplotlib 日本語設定のときに使うコマンド

matplotlib 日本語フォント

日本語設定のときに使うコマンド

# 設定ファイルの場所確認
matplotlib.matplotlib_fname()
#> C:\Users\daisuke.oda\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\mpl-data\matplotlibrc

# システムフォントファイル一覧
matplotlib.font_manager.findSystemFonts()

# フォント名の確認
font_file = 'c:\\windows\\fonts\\rictydiminished-regular_0.ttf'
matplotlib.font_manager.FontProperties(fname=font_file).get_name()
#> Ricty diminishied

# フォント設定
matplotlib.rc('font', **{'family':'IPAexGothic'})

matplotlib.rc()で設定すれば特に設定ファイルは変更する必要ない毎回面倒なときは以下

# 設定ディレクトリ作成
$ mkdir ~/.matplotlib

# デフォルトコピー
$ cp C:\Users\<user>\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\mpl-data\matplotlibrc ~/.matplotlib/

#> 編集する
# キャッシュファイル削除
$ rm font*cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment