Hello,

I've been using Matplotlib to generate postscript (eps) graphics which I 
import into my latex documents.  I tried using Latex to typeset mathematical 
symbols on my plots using the steps described here:

http://www.scipy.org/Cookbook/Matplotlib/UsingTex

The problem (I think) is that the eps files are genrated using dvipng, which 
results in ugly figures in the final PDF output. Is there a way to get 
Matplotlib to *not* use dvipng as the backend?  

For example. If I use the following simple script to generate a eps file

=========================================
from matplotlib import rc
import pylab
from pylab import *
import numarray as na
params = {
        'backend': 'ps',
        'axes.titlesize':  24,
        'axes.labelsize':  18,
        'xtick.labelsize': 14,
        'ytick.labelsize': 14,
        'legend.fontsize': 14
        }
pylab.rcParams.update(params)
#rc('text', usetex=True)
N = 4
ind = arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars
data01 = (5, 10, 3, 2)
data02 = (3, 7, 10, 6)
title('Normal EPS Generation')
p1 = bar(ind, data01, width, color='#CCCCFF')
p2 = bar(ind+width, data02, width, color='#3399FF')
xticks(ind+width, ('1', '2', '3', '4') )
xlim(-width,len(ind))
legend( (p1[0], p2[0]), ('data01', 'data02'), loc='upper right', shadow=False)
pylab.savefig('test.eps')
=============================================

I get a nice EPS file which looks good in my final PDF.  Also, running ps2pdf 
and pdffonts shows that all the fonts are properly embedded in the eps file:

======================
$ ps2pdf test.eps
$ pdffonts test.pdf
name                                 type         emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------
NBOBDW+BitstreamVeraSans-Roman       TrueType     yes yes no       8  0
=======================

So as one would expect, the plots look good in the final PDF when zooming in 
and out because all the fonts are there.  On the other hand, if I uncomment 
the "rc('text', usetex=True)" line in the script so that Latex is used for 
the fonts, I get the following when converting the resulting EPS file to PDF:

=======================
$ ps2pdf test.eps
$ pdffonts test.pdf
name                                 type         emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------

=======================

As you can see, there's no font embedding in this case and the image looks bad 
when previewed in either Ghotsview (eps) or in PDF.  Does anyone know if it's 
possible to get Matplotlib + Latex font embedding to work?

Regards,
Stephan


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to