Wie man matplotlib findfont behebt: Font family 'xkcd' not found auf Ubuntu 22.04+

Problem:

Beim Plotten eines XKCD-Stil-Plots mit matplotlib sehen Sie die folgenden Fehlermeldungen:

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.

Lösung

Installieren Sie die Humor Sans-Schriftart mit

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

Zusätzlich müssen Sie den matplotlib-Schriftart-Cache entfernen:

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

Check out similar posts by category: Linux, Python