The following script:
import matplotlib
matplotlib.use(\'Agg\')
import matplotlib.pyplot as mpl
mpl.rc(\'font\', family=\'sans-serif\')
mpl.rc(\'text\', use
The easiest way is to use matplotlib's internal TeX, e.g.:
import pylab as plt
params = {'text.usetex': False, 'mathtext.fontset': 'stixsans'}
plt.rcParams.update(params)
If you use an external LaTeX, you can use, e.g., CM Bright fonts:
params = {'text.usetex': True,
'text.latex.preamble': [r'\usepackage{cmbright}', r'\usepackage{amsmath}']}
plt.rcParams.update(params)
Note, that the CM Bright font is non-scalable, and you'll not be able to save PDF/PS! Same with other options with external LaTeX I've found so far.