Thanks for the quick reply Darren.
Generating .eps files has never worked for me, I think I tried this with 0.86
and 0.87.2 as well. In the script I changed the extension from ps to eps,
this gives an error. I get the same error with the very simple script:
from scipy import *
from pylab import *
n=100
x=arange(n)
y=rand(n)
figure(1)
clf()
plot(x, y)
savefig('test.eps')
show()
Could replacing the code on line 1179 in backend_ps as you suggested solve
this?
The traceback of the above script:
exceptions.ValueError Traceback (most recent
call last)
/home/rgommers/data/python/test.py
8 clf()
9 plot(x, y)
---> 10 savefig('test.eps')
11 show()
12
/usr/lib/python2.3/site-packages/matplotlib/pylab.py in savefig(*args,
**kwargs)
800 def savefig(*args, **kwargs):
801 fig = gcf()
--> 802 return fig.savefig(*args, **kwargs)
803 if Figure.savefig.__doc__ is not None:
804 savefig.__doc__ = _shift_string(Figure.savefig.__doc__)
/usr/lib/python2.3/site-packages/matplotlib/figure.py in savefig(self, *args,
**kwargs)
656 kwargs[key] = rcParams['savefig.%s'%key]
657
--> 658 self.canvas.print_figure(*args, **kwargs)
659
660 def colorbar(self, mappable, cax=None,
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py in
print_figure(self, outfile, dpi, facecolor, edgecolor, orientation,
papertype)
995 # Let's keep the usetex stuff seperate from the generic
postscript
996 self._print_figure_tex(outfile, dpi, facecolor, edgecolor,
--> 997 orientation, papertype)
998 else:
999 if isinstance(outfile, file):
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py in
_print_figure_tex(self, outfile, dpi, facecolor, edgecolor, orientation,
papertype)
1223
1224 if rcParams['ps.usedistiller'] == 'ghostscript':
-> 1225 gs_distill(tmpfile, ext=='.eps', ptype=papertype,
bbox=bbox)
1226 elif rcParams['ps.usedistiller'] == 'xpdf':
1227 xpdf_distill(tmpfile, ext=='.eps', ptype=papertype,
bbox=bbox)
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py in
gs_distill(tmpfile, eps, ptype, bbox)
1329 shutil.move(outputfile, tmpfile)
1330 if eps:
-> 1331 pstoeps(tmpfile, bbox)
1332
1333
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py in
pstoeps(tmpfile, bbox)
1418 Convert the postscript to encapsulated postscript.
1419 """
-> 1420 bbox_info = get_bbox(tmpfile, bbox)
1421
1422 epsfile = tmpfile + '.eps'
/usr/lib/python2.3/site-packages/matplotlib/backends/backend_ps.py in
get_bbox(tmpfile, bbox)
1393 ## bbox_info = stderr.read()
1394 verbose.report(bbox_info, 'helpful')
-> 1395 l, b, r, t = [float(i) for i in bbox_info.split()[-4:]]
1396
1397 # this is a hack to deal with the fact that ghostscript does not
return the
ValueError: invalid literal for float(): cidfmap
WARNING: Failure executing file: <test.py>
Cheers,
Ralf
···
On Friday 21 April 2006 14:24, Darren Dale wrote:
On Friday 21 April 2006 08:35, Ralf Gommers wrote:
> Hi everyone,
>
> I upgraded from version 87.2 to svn (on linux) two days ago, and I
> noticed that the output to posscript files has changed. The relevant rc
> settings are:
>
> text.usetex : True
> ps.papersize : A4
> ps.useafm : True # use of afm fonts, results in small files
> ps.usedistiller : ghostscript
>
> The results for a typical picture with both 87.2 and svn are attached.
> I'm guessing that _svn is the correct behavior since the papersize is A4
> here, as specified in the rc. But when I use ps2eps the 87.2 version
> comes out correct and the svn version does not. I tried ps.papersize:
> auto as well, but then the eps file is only half the graph.
It looks like ghostscript is not calculating the bounding box properly when
it distills your file. I have done a lot of testing and havent seen this
problem. Try replacing the bounding box code on line 1179 in backend_ps
with this:
if ext=='.eps': print >>fh, "%%%%BoundingBox: %d %d %d %d" % bbox
That might help things a little. Note, if your figure runs off the
postscript page, conversion to eps may result in a clipped image. It's
better to ask mpl to make an eps file in the first place.
Darren