Python matplotlib: all about fonts

Fonts output into pdf as text, not shape, to be recognized in Illustrator:

import matplotlib
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42

Change fonts style for all, change the default:

import matplotlib as mpl
matplotlib.rcParams['font.family'] = 'Arial'

Change fonts style for labels, tick marks, and titles: (for each plot, not changing the default)

plt.xlabel('XXXX', fontsize=12, fontname='Arial')
plt.ylabel('XXXXX', fontsize=12, fontname='Arial')

plt.xticks(fontname='Arial')
plt.yticks(fontname='Arial')

plt.title('XXXXX', fontsize=14, fontname='Arial')

Change legend font style: (for each plot, not changing the default)

plt.legend(prop=matplotlib.font_manager.FontProperties(family='Arial', size=12, weight='bold', style='normal'))

Source:
https://jonathansoma.com/lede/data-studio/matplotlib/exporting-from-matplotlib-to-open-in-adobe-illustrator/
https://stackoverflow.com/questions/20753782/default-fonts-in-seaborn-statistical-data-visualization-in-ipython
https://stackoverflow.com/questions/47112522/matplotlib-how-to-set-legends-font-type
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html