when using TeX, how can I specify san serif ticklabels

Hi all,
I prefer san serif ticklabels on my matplotlib plots. Can anyone suggest an easy of making this happen when using TeX/LateX to handle text?
Cheers,
Cory.

···

--
---------------------------------------------------
Cory Davis
Institute for Atmospheric and Environmental Science
Room 307, Crew Building, Kings Buildings,
University of Edinburgh. Edinburgh EH9 3JN
phone: +44 131 6505092
www: http://www.geos.ed.ac.uk/contacts/homes/cdavis

Cory Davis wrote:

Hi all,
I prefer san serif ticklabels on my matplotlib plots. Can anyone suggest
an easy of making this happen when using TeX/LateX to handle text?

Update to the latest CVS, and I believe everything will Just Work.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

Thanks Robert,
Unfortunately I can't easily do this on my work machine. Our sys-admins installed matplotlib release version 0.83.2. If your change is already in 0.84 I can get them to upgrade, but I don't think they are so keen on CVS. Can you suggest a quick hack in the meantime?

Cheers,
Cory.

Robert Kern wrote:

···

Cory Davis wrote:

Hi all,
I prefer san serif ticklabels on my matplotlib plots. Can anyone suggest
an easy of making this happen when using TeX/LateX to handle text?

Update to the latest CVS, and I believe everything will Just Work.

--
---------------------------------------------------
Cory Davis
Institute for Atmospheric and Environmental Science
Room 307, Crew Building, Kings Buildings,
University of Edinburgh. Edinburgh EH9 3JN
phone: +44 131 6505092
www: http://www.geos.ed.ac.uk/contacts/homes/cdavis

Thanks Robert,
Unfortunately I can’t easily do this on my work machine. Our sys-admins
installed matplotlib release version 0.83.2. If your change is already
in 0.84 I can get them to upgrade, but I don’t think they are so keen on

CVS. Can you suggest a quick hack in the meantime?

Have you read this page: http://matplotlib.sourceforge.net/fonts.html ?

If not, then a brief summary is: You should be able set the default
font in your matplotlibrc file. If you want the labels to be
different than the rest of the plot, then you’ll need to create a
FontProperties object and pass it to the axes.set_xlabel() method
before plotting, i.e.

myaxes = plot(…)

myfont = FontProperties(fontfamily=‘sanserif’)

myaxes.set_label(‘my text’, fontdict=myfont)

plot(…)

See also the font_properties_demo.py

– Paul

···

On 11/8/05, Cory Davis <cdavis@…372…> wrote:

Cheers,
Cory.

Robert Kern wrote:

Cory Davis wrote:

Hi all,
I prefer san serif ticklabels on my matplotlib plots. Can anyone suggest
an easy of making this happen when using TeX/LateX to handle text?

Update to the latest CVS, and I believe everything will Just Work.

Cory Davis
Institute for Atmospheric and Environmental Science
Room 307, Crew Building, Kings Buildings,
University of Edinburgh. Edinburgh EH9 3JN

phone: +44 131 6505092
www: http://www.geos.ed.ac.uk/contacts/homes/cdavis


SF.Net email is sponsored by:

Tame your development challenges with Apache’s Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony™PSP. Click here to play:
http://sourceforge.net/geronimo.php


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net

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

Paul Barrett wrote:

    Thanks Robert,
    Unfortunately I can't easily do this on my work machine. Our sys-admins
    installed matplotlib release version 0.83.2. If your change is already
    in 0.84 I can get them to upgrade, but I don't think they are so
    keen on
    CVS. Can you suggest a quick hack in the meantime?

Have you read this page: http://matplotlib.sourceforge.net/fonts.html ?

It used to be that those settings were not honored when using (La)TeX.

The relevant changes are in texmanager.py (and I don't recall if they
are in 0.84).

    def get_tex_command(self, tex, fname):

        fontcmd = {'sans-serif' : r'{\sffamily %s}',
                   'monospace' : r'{\ttfamily %s}'}.get(
            rcParams['font.family'], r'{\rmfamily %s}')
        tex = fontcmd % tex

Add that snippet to the method and you should be good to go.

···

On 11/8/05, *Cory Davis* <cdavis@…372… > <mailto:cdavis@…372…>> wrote:

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

Thanks Robert,

The relevant changes are in texmanager.py (and I don't recall if they
are in 0.84).

    def get_tex_command(self, tex, fname):

        fontcmd = {'sans-serif' : r'{\sffamily %s}',
                   'monospace' : r'{\ttfamily %s}'}.get(
            rcParams['font.family'], r'{\rmfamily %s}')
        tex = fontcmd % tex

Add that snippet to the method and you should be good to go.

This is not in 0.84, so I guess I will wait for the next release.
Cheers,
Cory.

···

--
---------------------------------------------------
Cory Davis
Institute for Atmospheric and Environmental Science
Room 307, Crew Building, Kings Buildings,
University of Edinburgh. Edinburgh EH9 3JN
phone: +44 131 6505092
www: http://www.geos.ed.ac.uk/contacts/homes/cdavis