Changing or adding fonts to Matplotlib

less than 1 minute read

When trying to change fonts in matplotlib, you might run into an error that says that the font or the font family was not found. To fix this, you need to actually add the font to matplotlib’s font database. For me, this is in /usr/share/matplotlib/mpl-data/fonts/ttf. Create a symbolic link to the font of your choice over here. Then use the name of the font package - open the font file with the default Font Viewer for this - in matplotlibrc to set your font preference.