I often want to make python plots with more attractive fonts than the matplotlib defaults. Luckily, matplotlib supports many alternative fonts. However, the vast majority of these appear not to be installed by default, and less savvy users (myself included) often encounter errors attesting to missing fonts. I'm asking this question hoping to both better understand matplotlib fonts in general and learn, by writing a MWE, how to install a font in e.g. Google Colab, which will hopefully serve as a guide for others with similar problems.
Font families. The docs state that there exist five valid font families: serif
, sans-serif
, cursive
, fantasy
, and monospace
. However, I find that, with a clean Linux install, cursive
is not found:
Is there a reason why a font family listed in the docs wouldn't be included by default? How can the cursive
family be added?
Specific Fonts. The Comic Sans MS
font is often used to demonstrate matplotlib fonts. However, it, too, does not work by default. This answer suggests running sudo apt install msttcorefonts -qq
and clearing a certain cache, but I find the font is still not found (though perhaps I'm doing something wrong). Here is a Colab notebook reproducing everything I have described.
I'd appreciate any guidance or enlightenment you can offer. If there's an alternative to matplotlib with comparable flexibility and better font control, I'd be happy to hear that, too.