solution
-
use FontBook app to install msyh.ttf
-
this will install msyh.ttf for
User
use, check my 2015-04-27-mac-font-locations-and-their-purposes$ cd ~/Library/Fonts; ls msyh.ttf
-
after install you will find out this font called
Microsoft YaHei
-
-
edit your
matplotlibrc
file-
find out
matplotlibrc
file$ python -c "import matplotlib; print matplotlib.matplotlib_fname()" /Users/hqlgree2/anaconda/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc
-
copy this file to your home folder
$ cd /Users/hqlgree2/anaconda/lib/python2.7/site-packages/matplotlib/mpl-data/ $ cp matplotlibrc ~/.matplotlib/matplotlibrc
-
make some edit and save
$ pico matplotlibrc # uncomment this line font.family : sans-serif # uncomment this line and add Microsoft YaHei font.sans-serif : Microsoft YaHei, Bitstream Vera Sans...
-
-
regenerate
fontList.cache
$ cd ~/.matplotlib $ rm fontList.cache $ python -c "import matplotlib.pyplot as plt" $ grep YaHei fontList.cache S'Microsoft YaHei'
-
use font in code
import matplotlib matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei'] matplotlib.rcParams['axes.unicode_minus'] = False
convert .dfont
to .ttf
-
install fondu use brew
$ brew install fondu # if got an error run brew update
-
convert
$ cd some_dir $ sudo fondu -show /System/Library/Fonts/Helvetica.dfont
convert .ttc
to .ttf
-
download dfontsplitter
-
drag
.ttc
file intodfontsplitter
app
find font on your system
-
you can use FontBook.app
find where matplotlib stores its data
$ python
>>> import matplotlib
>>> matplotlib.matplotlib_fname()
/Users/hqlgree2/anaconda/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc
or
$ python -c "import matplotlib; print matplotlib.matplotlib_fname()"
/Users/hqlgree2/anaconda/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc