matplotlib font not found

前端 未结 1 724
忘了有多久
忘了有多久 2020-12-10 11:07

I\'m trying to use the font \"Heuristica\" in my matplotlib plots, but it won\'t show up.

I defined \"Heuristica\" on the first spot in the rcParameter font.serif --

相关标签:
1条回答
  • 2020-12-10 11:51

    Well, mdboom solved the problem over at github, all the credit belongs to him:

    When you add new fonts to your system, you need to delete your fontList.cache file in order for matplotlib to find them.

    The reason it works on lines 4/5 in your example is because you are creating a FontManager from scratch (which goes out to the filesystem and hunts down all the fonts). Internally, when matplotlib later does its own font lookup, it is using a FontManager that has been loaded from a cache on disk in the fontList.cache file.

    Long term, we have plans to switch to using the font lookup mechanisms of the OS to get around this problem, (see MEP14), but in the meantime, you'll need to remove the fontList.cache file everytime you want matplotlib to discover new fonts.

    The file fontList.cache is located at your Userfolder --> .matplotlib/fontList.cache, for Windows that would normally be C:\Users\yourUsername\.matplotlib\fontList.cache

    0 讨论(0)
提交回复
热议问题