Question

I'm writing my thesis in the Arno Pro font and I wanted the font in my images (which I make using matplotlib) to match that of my thesis. The documentation of matplotlib claims that:

The font.family property has five values: 'serif' (e.g., Times),
'sans-serif' (e.g., Helvetica), 'cursive' (e.g., Zapf-Chancery),
'fantasy' (e.g., Western), and 'monospace' (e.g., Courier).

Is it posible to use Arno Pro or other font families in the labels of matplotlib? If so, how?

Thank you.

Was it helpful?

Solution

One can find all of the available fonts using the font manager:

import matplotlib.font_manager
print matplotlib.font_manager.findSystemFonts(fontpaths=None)

This will print a list of all fonts available, I couldn't find Arno Pro, but maybe is you can find a .ttf file for it (or something similar) then doing something like the following

import matplotlib.pylab as plt

plt.rcParams['font.family']='Sawasdee'

mpl.pylab.plot(range(10), mpl.pylab.sin(range(10)))
mpl.pylab.xlabel("Some crazy font", size=20)

produces: enter image description here

Note I simplify picked a random file from the font manager output called Sawasdee so this may not be installed on your computer and will throw an error.

Obviously this font is also producing some errors so you'll have to watch out for those, good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top