Hi

I finally managed to write a simplified version of my python script
which crashes when trying to save the figure as a postscript file. (this
is related to a previous post). See below. The script is provided, as
well as the full error message.

Sorry for the long script, but basically I am plotting 3x7 arrays via
pcolormesh. The script looks pretty dum because it was adapted from a
more complicated one where the bins/pixels are not exactly squared and
are rotated. In the version below I have tried to remove the unncessary
complication. And I get a failure from ghostscript when I try to save it
as eps. It works when I save it as a png.

Can anyone tell me what's wrong there? Again I am using:

### On an OpenSuse 11.2, 64b
xpdf distiller (but I tried others).
matplotlib 0.99.1.1
backend WXAgg version 2.8.10.1
Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21)
IPython 0.10 -- An enhanced Interactive Python.


THANKS
Eric
====================================================================

######################################################################
# Script to run which crashes when saving the figure as an eps file
######################################################################
#!/usr/bin/python
import numpy as num
import pylab as pl

def  pos(i,j, w, h) :
   return [0.05+ j*(w+0.02), 0.99 -  (i+1)*(h+0.023)+0.025, w, h]


## Opening the figure
## Figure
pl.figure(1, figsize=(5*1.2, 7*1.5))
fig = pl.gcf()
pl.clf()

## Size of figure
figH = fig.get_figheight()
figW = fig.get_figwidth()
w = 0.99 / 3. -0.03
h =  0.99 / 7 - 0.022

## List of data to plot (I take 7 times the same stuff)
listgal = ["1","2","3","4","5","6",",7"]

## Initialisation of start, end and step
ngal = len(listgal)
start = [-30.,-30.]
end = [30.,30.]
npix = [80,80]
x = num.linspace(start[0],end[0], npix[0])
y = num.linspace(start[1],end[1], npix[1])
step = [x[1]-x[0], y[1]-y[0]]
X,Y = num.meshgrid(x,y)

## Initialisation of data
data = num.random.random((npix[0], npix[1]))

pl.ioff()
for k in range(ngal) :
   gal = listgal[k]

   ## Coordinates

   ## Grid for rotation
   Xp,Yp = X - step[0]/2., Y - step[1]/2.
   X1,Y1 = X+step[0]/2.,Y+step[1]/2.
   X2,Y2 = X-step[0]/2.,Y+step[1]/2.
   X3,Y3 = X-step[0]/2.,Y-step[1]/2.
   X4,Y4 = X+step[0]/2.,Y-step[1]/2.
   minXc = num.min(num.concatenate((X1,X2,X3,X4)))
   maxXc = num.max(num.concatenate((X1,X2,X3,X4)))
   minYc = num.min(num.concatenate((Y1,Y2,Y3,Y4)))
   maxYc = num.max(num.concatenate((Y1,Y2,Y3,Y4)))
   dX = maxXc - minXc
   dY = maxYc - minYc

   ## Deriving the right aspect ratio etc
   aspectIma = dX / dY
   aspectFig = figW / figH
   aspectWin = w / h
   if (aspectIma < aspectWin*aspectFig) :
      maxXc = maxXc * aspectFig * aspectWin / aspectIma
      minXc = minXc * aspectFig * aspectWin / aspectIma
   else :
      maxYc = maxYc * aspectIma / (aspectFig * aspectWin)
      minYc = minYc * aspectIma / (aspectFig * aspectWin)
   extentR = minXc, maxXc, minYc, maxYc

   cmap = pl.cm.jet
   minI, maxI = 0., 1.
   cmap.set_bad('w',1.0)
   j = 0
   ax1 = fig.add_axes(pos(k,j, w, h))
   map1 = ax1.pcolormesh(Xp,Yp,data,shading='flat',vmin=minI,vmax=maxI,
cmap=cmap)
   pl.plot([0.],[0.],'k+', markersize=10, lw=3)
   xticklabels = pl.getp(pl.gca(), 'xticklabels')
   pl.setp(xticklabels, fontsize=8)
   yticklabels = pl.getp(pl.gca(), 'yticklabels')
   pl.setp(yticklabels, fontsize=8)
   pl.axis(extentR)
   j += 1

   ax2 = fig.add_axes(pos(k,j, w, h))
   map2 = ax2.pcolormesh(Xp,Yp,data,shading='flat',vmin=minI,vmax=maxI,
cmap=cmap)
   pl.plot([0.],[0.],'k+', markersize=10, lw=3)
   pl.axis(extentR)
   ax2.set_yticks([])
   xticklabels = pl.getp(pl.gca(), 'xticklabels')
   pl.setp(xticklabels, fontsize=8)
   pl.text(0.02,0.96, "%4.0f/%4.0f"%(minI,maxI),
verticalalignment='top',rotation='vertical',transform = ax2.transAxes,
fontsize=8)
   j += 1

   ax3 = fig.add_axes(pos(k,j, w, h))
   map2 = ax3.pcolormesh(Xp,Yp,data,shading='flat',vmin=0.,vmax=1.,
cmap=cmap)
   pl.plot([0.],[0.],'k+', markersize=10, lw=3)
   pl.axis(extentR)
   ax3.set_yticks([])
   xticklabels = pl.getp(pl.gca(), 'xticklabels')
   pl.setp(xticklabels, fontsize=8)
   pl.text(0.02,0.96, "%4.0f/%4.0f"%(minI,maxI),
verticalalignment='top',rotation='vertical',transform = ax3.transAxes,
fontsize=8)
   j += 1
   pl.text(0.92,0.5, gal,
rotation='vertical',verticalalignment='center',transform = ax3.transAxes)

   k += 1

pl.ion()
pl.show()

#######################################################################
## ERROR MESSAGE WHEN DOING:
## savefig("tmp.eps")
########################################################################
savefig("toto.eps")
Error: /limitcheck in --def--
Operand stack:
   pa_c2c   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--
--nostringval--   2   %stopped_push   --nostringval--   --nostringval--
  --nostringval--   false   1   %stopped_push   1878   1   3
%oparray_pop   1877   1   3   %oparray_pop   1861   1   3   %oparray_pop
  1755   1   3   %oparray_pop   --nostringval--   %errorexec_pop
.runexec2   --nostringval--   --nostringval--   --nostringval--   2
%stopped_push   --nostringval--

Dictionary stack:

   --dict:1171/3371(ro)(G)--   --dict:1/20(G)--   --dict:74/200(L)--
--dict:5/6(ro)(L)--   --dict:179/300(L)--   --dict:44/200(L)--
--dict:65534/65534(L)--

Current allocation mode is local

Last OS error: 2

Current file position is 14229051

GPL Ghostscript 8.64: Unrecoverable error, exit code 1

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

RuntimeError                              Traceback (most recent call
last)

/science/ATLAS3D/python/Analysis/Try.py in <module>()
----> 1
      2
      3
      4
      5

/usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in
savefig(*args, **kwargs)
    354 def savefig(*args, **kwargs):

    355     fig = gcf()

--> 356     return fig.savefig(*args, **kwargs)

    357 if Figure.savefig.__doc__ is not None:

    358     savefig.__doc__ = dedent(Figure.savefig.__doc__)


/usr/lib64/python2.6/site-packages/matplotlib/figure.pyc in
savefig(self, *args, **kwargs)
   1030                 patch.set_alpha(0.0)

   1031

-> 1032         self.canvas.print_figure(*args, **kwargs)

   1033

   1034         if transparent:


/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_wxagg.pyc
in print_figure(self, filename, *args, **kwargs)
     98     def print_figure(self, filename, *args, **kwargs):

     99         # Use pure Agg renderer to draw


--> 100         FigureCanvasAgg.print_figure(self, filename, *args,
**kwargs)
    101         # Restore the current view; this is needed because the


    102         # artist contains methods rely on particular attributes


/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.pyc in
print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
format, **kwargs)

   1474                 orientation=orientation,

   1475                 bbox_inches_restore=_bbox_inches_restore,

-> 1476                 **kwargs)

   1477         finally:

   1478             if bbox_inches and restore_bbox:


/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.pyc in
print_eps(self, *args, **kwargs)
   1327         from backends.backend_ps import FigureCanvasPS # lazy
import
   1328         ps = self.switch_backends(FigureCanvasPS)

-> 1329         return ps.print_eps(*args, **kwargs)

   1330

   1331     def print_pdf(self, *args, **kwargs):


/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_ps.pyc in
print_eps(self, outfile, *args, **kwargs)
    853

    854     def print_eps(self, outfile, *args, **kwargs):

--> 855         return self._print_ps(outfile, 'eps', *args, **kwargs)

    856

    857


/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_ps.pyc in
_print_ps(self, outfile, format, *args, **kwargs)
    882             self._print_figure_tex(outfile, format, imagedpi,
facecolor, edgecolor,
    883                                    orientation, isLandscape,
papertype,
--> 884                                    **kwargs)

    885         else:

    886             self._print_figure(outfile, format, imagedpi,
facecolor, edgecolor,

/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_ps.pyc in
_print_figure_tex(self, outfile, format, dpi, facecolor, edgecolor,
orientation, isLandscape, papertype, **kwargs)

   1188             gs_distill(tmpfile, isEPSF, ptype=papertype,
bbox=bbox)
   1189         elif rcParams['ps.usedistiller'] == 'xpdf':

-> 1190             xpdf_distill(tmpfile, isEPSF, ptype=papertype,
bbox=bbox)
   1191         elif rcParams['text.usetex']:

   1192             if False: pass # for debugging


/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_ps.pyc in
xpdf_distill(tmpfile, eps, ptype, bbox)
   1345     fh = file(outfile)
   1346     if exit_status: raise RuntimeError('ps2pdf was not able to
process your \
-> 1347 image.\n\Here is the report generated by ghostscript:\n\n' +
fh.read())
   1348     else: verbose.report(fh.read(), 'debug')
   1349     fh.close()

RuntimeError: ps2pdf was not able to process your image.
\Here is the report generated by ghostscript:


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to