I have been trying to change the default font to Arial. I wanted to change it permanently, so edited the matplotlibrc file which holds all the default settings. To find the file:

import matplotlib
print matplotlib.matplotlib_fname()

Now, add these lines to the file:

font.family         : sans-serif
font.sans-serif     : Arial

To see the change, you have to close python and boot up again so that it does not pull anything from the cache. If you want to change the font size you can edit the file. However, that didn’t work so I changed the font size in the plotting file.

font = {'size'   : 18}
matplotlib.rc('font', **font)

If you want to directly change the font, use this in the plotting file.

from matplotlib import rc
font = {'size'   : 16}
matplotlib.rc('font', **font)
## for Palatino and other serif fonts use:
#rc('text', usetex=True)

# change font
matplotlib.rcParams['font.sans-serif'] = "Arial"
matplotlib.rcParams['font.family'] = "sans-serif"

Last modified: 2017-12-31