Switching between different font settings

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

So far I've tried reading a file with settings specific to the current
document and using "rcParams.update(params)" to dynamically change the
settings.

This seems to me to be a good way of switching between settings.

This way I can get the right font for legends and labels, but
I have not figured out how to get correct fonts for the numbers
on the x- and y-axes. Matplotlib uses whatever is default in my LaTeX
installation (Computer Modern?). I use "text.usetex: True".

The usetex support attempts to select a font from the same list used by
matplotlib otherwise. I'm not sure if it's properly documented anywhere,
but the machinery is in texmanager.py, and here's the relevant data
structure:

font_info = {'new century schoolbook': ('pnc',
r'\renewcommand{\rmdefault}{pnc}'),
'bookman': ('pbk', r'\renewcommand{\rmdefault}{pbk}'),
'times': ('ptm', r'\usepackage{mathptmx}'),
'palatino': ('ppl', r'\usepackage{mathpazo}'),
'zapf chancery': ('pzc', r'\usepackage{chancery}'),
'cursive': ('pzc', r'\usepackage{chancery}'),
'charter': ('pch', r'\usepackage{charter}'),
'serif': ('cmr', ''),
'sans-serif': ('cmss', ''),
'helvetica': ('phv', r'\usepackage{helvet}'),
'avant garde': ('pag', r'\usepackage{avant}'),
'courier': ('pcr', r'\usepackage{courier}'),
'monospace': ('cmtt', ''),
'computer modern roman': ('cmr', ''),
'computer modern sans serif': ('cmss', ''),
'computer modern typewriter': ('cmtt', '')}

What font are you trying to use? Is it one of those listed above?

Since you say that you get the right font for legends and labels but not
for tick labels, perhaps the problem is with math mode. What font do you
get if you typeset a formula? Try something like

text(r'\$1+2+3={}\$1+2+3')

to see if the math font is different from the text font.

···

--
Jouni K. Sepp�nen
http://www.iki.fi/jks

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? I’ve tried to set ‘mathtext.rm’: ‘sans-serif’ in my params dict
and then run “rcParams.update(params)” but that did not help. Do you know what I should do?

// Johan

···

On Mon, Jan 5, 2009 at 2:06 PM, Jouni K. Seppänen <jks@…397…> wrote:

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

So far I’ve tried reading a file with settings specific to the current

document and using “rcParams.update(params)” to dynamically change the

settings.

This seems to me to be a good way of switching between settings.

This way I can get the right font for legends and labels, but

I have not figured out how to get correct fonts for the numbers

on the x- and y-axes. Matplotlib uses whatever is default in my LaTeX

installation (Computer Modern?). I use “text.usetex: True”.

The usetex support attempts to select a font from the same list used by

matplotlib otherwise. I’m not sure if it’s properly documented anywhere,

but the machinery is in texmanager.py, and here’s the relevant data

structure:

``````font_info = {'new century schoolbook': ('pnc',

r'\renewcommand{\rmdefault}{pnc}'),

'bookman': ('pbk', r'\renewcommand{\rmdefault}{pbk}'),

'times': ('ptm', r'\usepackage{mathptmx}'),

'palatino': ('ppl', r'\usepackage{mathpazo}'),

'zapf chancery': ('pzc', r'\usepackage{chancery}'),

'cursive': ('pzc', r'\usepackage{chancery}'),

'charter': ('pch', r'\usepackage{charter}'),

'serif': ('cmr', ''),

'sans-serif': ('cmss', ''),

'helvetica': ('phv', r'\usepackage{helvet}'),

'avant garde': ('pag', r'\usepackage{avant}'),

'courier': ('pcr', r'\usepackage{courier}'),

'monospace': ('cmtt', ''),

'computer modern roman': ('cmr', ''),

'computer modern sans serif': ('cmss', ''),

'computer modern typewriter': ('cmtt', '')}
``````

What font are you trying to use? Is it one of those listed above?

Since you say that you get the right font for legends and labels but not

for tick labels, perhaps the problem is with math mode. What font do you

get if you typeset a formula? Try something like

text(r’\$1+2+3={}\$1+2+3’)

to see if the math font is different from the text font.

Jouni K. Seppänen

http://www.iki.fi/jks

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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