The following script:
import matplotlib
matplotlib.use(\'Agg\')
import matplotlib.pyplot as mpl
mpl.rc(\'font\', family=\'sans-serif\')
mpl.rc(\'text\', use
I always have text.usetex = True in my matplotlibrc file. In addition to that, I use this as well:
mpl.rcParams['text.latex.preamble'] = [
r'\usepackage{siunitx}', # i need upright \micro symbols, but you need...
r'\sisetup{detect-all}', # ...this to force siunitx to actually use your fonts
r'\usepackage{helvet}', # set the normal font here
r'\usepackage{sansmath}', # load up the sansmath so that math -> helvet
r'\sansmath' # <- tricky! -- gotta actually tell tex to use!
]
Hope that helps.