How to get XKCD font working in matplotlib How to get XKCD font working in matplotlib python-3.x python-3.x

How to get XKCD font working in matplotlib


Try deleting Matplotlib cache and see if it works (i.e., rm -r ~/.cache/matplotlib).

In my case it solved the problem:

user@host:~$ ./xkcd.py/home/user/.pyenv/versions/3.7.1/lib/python3.7/site-packages/matplotlib/font_manager.py:1241:UserWarning: findfont: Font family ['xkcd', 'Humor Sans', 'Comic Sans MS'] not found.Falling back to DejaVu Sans. (prop.get_family(), self.defaultFamily[fontext]))user@host:~$ rm -r ~/.cache/matplotlibuser@host:~$ ./xkcd.pyuser@host:~$


If you still see an error after installing HumorSans font, I advise running:

import matplotlibmatplotlib.font_manager._rebuild()

It will rebuild the font cache.