Matplotlib cannot find basic fonts

后端 未结 10 810
一生所求
一生所求 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 00:58

    A solution for Windows users, when confronted with the warning:

    UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans
    (prop.get_family(), self.defaultFamily[fontext]))
    
    1. Delete the fonts located in matplotlib's cache.
      Cache's location: import matplotlib as mpl; print(mpl.font_manager.get_cachedir())

    2. Find matplotlib's font directory. The path might be similar to
      C:\Miniconda3\pkgs\matplotlib-2.2.2-py36_1\Lib\site-packages\matplotlib\mpl-data\fonts\ttf

    3. Copy necessary fonts like Computer Modern to this directory.

    The warning may persist, but your plots' font should change appropriately.

提交回复
热议问题