Fonts for eps files

I can confirm that this is broken in 0.98.3 and fixed in SVN. It's not clear if a simple patch is possible -- the fix actually extends over a number of changesets.

If you're able to build from SVN, I'm rather certain that should resolve this issue. Otherwise, you may have to wait for the next release.

Cheers,
Mike

John Mariska wrote:

···

Hi Mike,

Thanks for the prompt response to my post. I've tried your solution and have not been successful. Am not running the svn head, but am at 0.98.3. Here is the little test code I have:

#!/usr/bin/env python

import numpy as np
import matplotlib as mpl
mpl.use('PS')
from matplotlib.pyplot import figure, show

mpl.rc('font', size=20)
mpl.rc('ps', useafm=True)
mpl.rc('text', usetex=False)

fig = figure()
fig.subplots_adjust(bottom=0.15, left=0.15)

x = np.arange(0.0, 10.2, 0.2)

ax = fig.add_subplot(111)
ax.plot(x, np.sin(x), 'bo')

ax.set_xlabel(r'x (cm$\mathsf{^{-3}}$)')
ax.set_ylabel(r'y (ergs cm$\mathsf{^{-2}}$ s$^{-1}$)')

show()
fig.savefig('test_latex.eps')

If I do a grep findfont test_latex.eps, the result is:

/Helvetica findfont
/BitstreamVeraSans-Roman findfont
/Cmsy10 findfont
/Cmr10 findfont
/BitstreamVeraSans-Roman findfont
/Helvetica findfont
/BitstreamVeraSans-Roman findfont
/Cmsy10 findfont
/Cmr10 findfont
/BitstreamVeraSans-Roman findfont
/Cmsy10 findfont
/Cmr10 findfont
/BitstreamVeraSans-Roman findfont

I've also messed with making the changes in the matplolibrc file, without complete success. It may just be that this area of matplotlib is still a moving target.

John M.

Michael Droettboom wrote:

If you have "ps.useafm" set to True, (and "text.usetex" set to False), the mathtext renderer will stick to the standard 35 ps fonts, with the obvious limitations in the number of symbols available, and no radical signs, etc. By default, all math is serif (in this case Times). You can force sans-serif (Helvetica), by wrapping the math in \mathsf{}, eg.

r'ergs cm$\mathsf{^{-2}}$ s$\mathsf{^{-1}}$'

Let me know if the above doesn't work for you. I only tested with SVN head.

Cheers,
Mike

John Mariska wrote:

Many scientific journals ask that authors submit figures as eps
files, preferably using one of the standard 35 ps fonts--usually
Helvetica or Times. I've been able to tweak the matplotlib.rc
file to make eps plot files that have all the numbers and labels
in Helvetica (or Times), but have a problem dealing with simple
superscipts and subscripts. Is there a way to get simple LaTeX
strings, such as r'ergs cm$^{-2}$ s$^{-1}$', to use only
Helvetica or Times?

John Mariska

-------------------------------------------------------------------------

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA