The default fonts for matplotlib are set in file matplotlibrc
in the folder $USER_HOME/.matplotlib
. You can find them here, depending on your operating system:
- Windows:
C:\Users\YourName\.matplotlib\matplotlibrc
- Linux:
/home/YourName/.matplotlib/matplotlibrc
Within the file, search for the font
section, and uncomment (remove the hash symbol #
at beginning of line) or add the following settings as desired. In the shown example, I set Arial as the default:
font.family : sans-serif #font.style : normal #font.variant : normal #font.weight : medium #font.stretch : normal # ... #font.serif : Times New Roman, ... font.sans-serif : Arial, ... #font.cursive : ... cursive #font.fantasy : ... fantasy #font.monospace : ... monospace
Upon the next start of the Python interpreter, your plots should be labelled with the new font.
Further reading
- Customizing matplotlib in the official documentation
- Change default font on the matplotlib mailining list, which explains an alternative way to change the font.