Switching between different font settings

"Johan Ekh" <ekh.johan@...287...> writes:

I am trying to use helvetica and yes, text(r'$1+2+3={}$1+2+3') gives me
helvetica for the non math mode case.
But how do I get math mode to use the same font?

You can't. The problem is that while Helvetica contains all the usual
letters and numbers, TeX math fonts must include Greek letters and a
variety of symbols. (There exists a commercial Helvetica-like math font
called HV Math from Micropress Inc.)

Instead of getting math mode to use Helvetica, you want to make the tick
labels use text mode. I don't think there is existing support for that
in Matplotlib, but take a look at the Formatter classes in ticker.py -
if the functionality of OldScalarFormatter is enough for you, use that,
otherwise you'll have to hack ScalarFormatter to do what you want. If
you want the labels to look like they do right now except for the font
of the numbers, I think you could just wrap every number in
\textsf{...}, but there could be problems with spacing.

I've tried to set 'mathtext.rm': 'sans-serif' in my params dict

The mathtext options have no effect in usetex mode - everything gets
rendered by TeX.

···

--
Jouni K. Sepp�nen

OK,
Thanks for your help.
// Johan

···

On Wed, Jan 7, 2009 at 7:36 PM, Jouni K. Seppänen <jks@…397…> wrote:

“Johan Ekh” <ekh.johan@…287…> writes:

I am trying to use helvetica and yes, text(r’$1+2+3={}$1+2+3’) gives me

helvetica for the non math mode case.

But how do I get math mode to use the same font?

You can’t. The problem is that while Helvetica contains all the usual

letters and numbers, TeX math fonts must include Greek letters and a

variety of symbols. (There exists a commercial Helvetica-like math font

called HV Math from Micropress Inc.)

Instead of getting math mode to use Helvetica, you want to make the tick

labels use text mode. I don’t think there is existing support for that

in Matplotlib, but take a look at the Formatter classes in ticker.py -

if the functionality of OldScalarFormatter is enough for you, use that,

otherwise you’ll have to hack ScalarFormatter to do what you want. If

you want the labels to look like they do right now except for the font

of the numbers, I think you could just wrap every number in

\textsf{…}, but there could be problems with spacing.

I’ve tried to set ‘mathtext.rm’: ‘sans-serif’ in my params dict

The mathtext options have no effect in usetex mode - everything gets

rendered by TeX.


Jouni K. Seppänen

http://www.iki.fi/jks


Check out the new SourceForge.net Marketplace.

It is the best place to buy or sell services for

just about anything Open Source.

http://p.sf.net/sfu/Xq1LFB


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users