LoginSignup
0
0

More than 1 year has passed since last update.

M1 MacでMatplotlibのフォントをHelveticaに変更できない

Posted at

問題

M1 MacでmatplotlibのフォントをHelveticaにして図を作成しようとしたが、エラーにより図が保存されない。

raise TTLibError("specify a font number between 0 and %d (inclusive)" % (numFonts - 1))
Fonttools ttlib ttliberror specify a font number between 0 and 5 inclusive

TL;DR

import matplotlib
print(matplotlib.matplotlib_fname())

-----result-----
/Users/USERNAME/.pyenv/shims/versions/3.9.1/lib/python3.9/site-packages/matplotlib/mpl-data/matplotlibrc

この実行で表示された以下のファイルにアクセスし、部分的な変更を行う。

#font.sans-serif : DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Helvetica, Lucid, Arial, Avant Garde, sans-serif

この行において、優先度を高めるためHelveticaを最初に表記するように変更する。

font.sans-serif : Helvetica, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Avant Garde, sans-serif
0
0
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
0
0