Matplotlib Font Families: Using Arno Pro or Other Fonts

I am writing a dissertation in Arno Pro font, and I need a font in my images (which I make using matplotlib) in accordance with my thesis. The matplotlib documentation states that:

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

Can I use Arno Pro or other font families in matplotlib tags? If so, how?

Thanks.

+4
source share
1 answer

You can find all available fonts using the font manager :

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

This will print a list of all available fonts, I could not find Arno Pro, but maybe you can find the .ttf file for it (or something similar), and then do 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 am making it easier to select a random file from the font manager output called Sawasdee , so this may not be installed on your computer and will cause an error.

Obviously, this font also creates some errors, so you will need to keep track of them, good luck!

+2
source

Source: https://habr.com/ru/post/1500187/


All Articles