H, I'm using sfmath, too. I actually wrote a helper function to switch fonts. The preambles are the result of long-term trial and error. Normally, my preambles include some more custom commands which I left out here because they would be distracting. I always wondered why matplotlib doesn't do this kind of font switching out of the box.
def setfont(font=font_default,unicode=True): r""" Set Matplotlibs rcParams to use LaTeX for font rendering. Revert all changes by calling rcdefault() from matplotlib. Parameters: ----------- font: string "Helvetica" "Times" "Computer Modern" usetex: Boolean Use unicode. Default: False. """ # Use TeX for all figure text! plt.rc('text', usetex=True) font = font.lower().replace(" ","") if font == 'times': # Times font = {'family':'serif', 'serif':['Times']} preamble = r""" \usepackage{color} \usepackage{mathptmx} """ elif font == 'helvetica': # Helvetica # set serif, too. Otherwise setting to times and then # Helvetica causes an error. font = {'family':'sans-serif','sans-serif':['Helvetica'], 'serif':['cm10']} preamble = r""" \usepackage{color} \usepackage[tx]{sfmath} \usepackage{helvet} """ else: # Computer modern serif font = {'family':'serif', 'serif':['cm10']} preamble = r""" \usepackage{color} """ if unicode: # Unicode for Tex #preamble = r"""\usepackage[utf8]{inputenc}""" + preamble # inputenc should be set automatically plt.rcParams['text.latex.unicode']=True #print font, preamble plt.rc('font',**font) plt.rcParams['text.latex.preamble'] = preamble Am 03.05.2013 um 16:08 schrieb Juergen Hasch <pyt...@elbonia.de>: >> >> The solution I use when I want all sans-serif out of TeX is to use the >> cmbright package, which can be turned on by adding: >> >> rc('text.latex', preamble=r'\usepackage{cmbright}') >> >> That may require installing the cmbright LaTeX package if you don't already >> have it. > > I am using the sfmath package for this purpose. > > There is a nice comparision of the different approaches to get sans-serif > math fonts at the bottom of the sfmath page: > http://dtrx.de/od/tex/sfmath.html > > > > ------------------------------------------------------------------------------ > Get 100% visibility into Java/.NET code with AppDynamics Lite > It's a free troubleshooting tool designed for production > Get down to code-level detail for bottlenecks, with <2% overhead. > Download for free and get started troubleshooting in minutes. > http://p.sf.net/sfu/appdyn_d2d_ap2 > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite It's a free troubleshooting tool designed for production Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://p.sf.net/sfu/appdyn_d2d_ap2 _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users