How to fix matplotlib findfont: Font family 'xkcd' not found on Ubuntu 22.04+

Problem:

While plotting an XKCD-style plot using matplotlib, you see the following error messages:

install_humor_sans.sh
findfont: Font family 'xkcd' not found.
findfont: Font family 'xkcd Script' not found.
findfont: Font family 'Comic Neue' not found.
findfont: Font family 'Comic Sans MS' not found.

Solution

Install the Humor Sans font using

example.sh
sudo apt -y install font-humor-sans

Additionally, you need to remove the matplotlib font cache:

example.sh
rm -rf ~/.cache/matplotlib

 

 


Check out similar posts by category: Linux, Python