On 05/02/2013 03:16 PM, Paul Hobson wrote:

On Thu, May 2, 2013 at 11:19 AM, Michael Droettboom <md...@stsci.edu <mailto:md...@stsci.edu>> wrote:

    I think the confusion here stems from the fact that you're mixing
    TeX and non-TeX font commands.

    This turns on TeX mode, so all of the text is rendered with an
    external TeX installation:

    rc('text', usetex=True)

    In this line, setting it to sans-serif will get passed along to
    TeX, but a specific ttf font name can not be used by TeX, so the
    second part (involving Helvetica) is ignored.  And setting the
    default body text in TeX does not (by default) change the math
    font.  This is (unfortunately standard TeX behavior).

    rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})

    This affects the font set used by matplotlib's internal mathtext
    renderer, and has no effect on TeX:

    rc('mathtext', fontset='stixsans')

    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 know all this stuff is confusing, but providing a flat interface
    over both the internal text rendering and the TeX rendering isn't
    really possible -- they have different views of the world -- and
    I'm actually not sure it's desirable.  Though I wonder if we
    couldn't make it more obvious (somehow) when the user is mixing
    configuration that applies to the different contexts.

    Mike


Mike,

Thanks for the guidance. I know this stuff is complicated and the work everyone has put into it to make it work is fantastic.

I now see that this was more of TeX issue than an MPL configuration issue. Your help prompted me to find this solution (similar to yours):
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!

Wow. That's some serious TeX voodoo magic! Want to work that into an example that we could include in the docs?

Cheers,
Mike
------------------------------------------------------------------------------
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

Reply via email to