Matplotlib cannot find basic fonts

后端 未结 10 803
一生所求
一生所求 2020-12-08 00:34

I am using matplotlib version 2.0.0 on Python 3 in a miniconda virtual environment. I am working on a unix scientific computing cluster where I don\'t have root privileges.

10条回答
  •  半阙折子戏
    2020-12-08 00:55

    I am in macOS with jupyter notebook, I solved with the following, first close your jupyter notebook. Then find out the font path by doing the following in Python

    import matplotlib
    print(matplotlib.matplotlib_fname())
    

    it prints /Users/zyy/anaconda2/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc for me, notice matplotlibrc is a file, not a directory.

    Then download font SimHei, and copy it to the directory fonts/ttf under the mpl-data/ directory above.

    Delete directory ~/.cache/matplotlib and restart your jupyter notebook, everything should be good.

提交回复
热议问题