crashes when using savefig for eps files


Hi,
I have a problem saving eps files in certain conditions. Unfortunately I
am unable to find a simple example which may be very illustrative here
to show you when it works and when it does not.
I include the error message below and so the question is: does anybody
have a hint of why the savefig fails and crashes?
(I tried to close('all'), rcdefaults, etc).
thanks for any input,
Eric
=================savefig('toto.eps')

Your figure is too big to fit on a4 paper. b4 paper will be used to
prevent clipping.
AFPL Ghostscript 8.51: Unrecoverable error, exit code 1

<details class='elided'>
<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>

>>
                       -- ====================================================================

Eric Emsellem Centre de Recherche Astrophysique de Lyon
9 av. Charles-Andre tel: +33 (0)4 78 86 83 84
69561 Saint-Genis Laval Cedex fax: +33 (0)4 78 86 83 86
France ====================================================================

emsellem@...419...[http://www-obs.univ-lyon1.fr/eric.emsellem](http://www-obs.univ-lyon1.fr/eric.emsellem)

</details>

did you try to fix the size of the figure and the dpi?

N.

Eric Emsellem wrote:

···

Hi,

I have a problem saving eps files in certain conditions. Unfortunately I
am unable to find a simple example which may be very illustrative here
to show you when it works and when it does not.
I include the error message below and so the question is: does anybody
have a hint of why the savefig fails and crashes?

(I tried to close('all'), rcdefaults, etc).

thanks for any input,

Eric

>> savefig('toto.eps')
  
Your figure is too big to fit on a4 paper. b4 paper will be used to
prevent clipping.
AFPL Ghostscript 8.51: Unrecoverable error, exit code 1
---------------------------------------------------------------------------
exceptions.NameError Traceback (most
recent call last)

/home/science/Sauron/AnalysisKin/Paper7/<ipython console>

/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py in
savefig(*args, **kwargs)
    809 def savefig(*args, **kwargs):
    810 fig = gcf()
--> 811 return fig.savefig(*args, **kwargs)
    812 if Figure.savefig.__doc__ is not None:
    813 savefig.__doc__ = _shift_string(Figure.savefig.__doc__)

/usr/local/lib/python2.4/site-packages/matplotlib/figure.py in
savefig(self, *args, **kwargs)
    673 kwargs[key] = rcParams['savefig.%s'%key]
    674
--> 675 self.canvas.print_figure(*args, **kwargs)
    676
    677 def colorbar(self, mappable, cax=None, **kw):

/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py
in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
**kwargs)
    112 try:
    113 agg.print_figure(filename, dpi, facecolor,
edgecolor,
--> 114 orientation, **kwargs)
    115 except IOError, msg:
    116 error_msg_gtk('Failed to save\nError message:
%s'%(msg,), self)

/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py
in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
**kwargs)
    486 ps = self.switch_backends(FigureCanvasPS)
    487 ps.print_figure(filename, dpi, facecolor, edgecolor,
--> 488 orientation, **kwargs)
    489 elif ext.find('pdf')>=0:
    490 from backend_pdf import FigureCanvasPdf

/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py
in print_figure(self, outfile, dpi, facecolor, edgecolor, orientation,
papertype)
    999 # Let's keep the usetex stuff seperate from the
generic postscript
   1000 self._print_figure_tex(outfile, dpi, facecolor,
edgecolor,
-> 1001 orientation, papertype)
   1002 else:
   1003 if isinstance(outfile, file):

/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py
in _print_figure_tex(self, outfile, dpi, facecolor, edgecolor,
orientation, papertype)
   1233 elif rcParams['text.usetex']:
   1234 if False: pass # for debugging
-> 1235 else: gs_distill(tmpfile, ext=='.eps',
ptype=papertype, bbox=bbox)
   1236
   1237 if isinstance(outfile, file):

/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py
in gs_distill(tmpfile, eps, ptype, bbox)
   1331 exit_status = os.system(command)
   1332 fh = file(outfile)
-> 1333 if exit_status: raise RuntimeError('ghostscript was not able
to process \
   1334 your image.\nHere is the full report generated by ghostscript: \
   1335 \n\n'% dvifile + fh.read())

NameError: global name 'dvifile' is not defined

--

Eric Emsellem emsellem@...419...
                           Centre de Recherche Astrophysique de Lyon
9 av. Charles-Andre tel: +33 (0)4 78 86 83 84
69561 Saint-Genis Laval Cedex fax: +33 (0)4 78 86 83 86
France http://www-obs.univ-lyon1.fr/eric.emsellem

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

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Just wondering: you wouldn't happen to plot a space character by itself, by
any chance ? I remmbr running into something similar (the dvifile not being
processed properly), and it turned out that I was trying to use r' ' for a
legend. Substituting it with '' (viz, empty character) did the trick.

My 2c would be to try plotting first with usetex=False, then add with
usetex=True but text group by text group (tick labels, legened) till you find
the culprit.

···

On Tuesday 17 October 2006 11:50, Humufr wrote:

did you try to fix the size of the figure and the dpi?

What MPL version are you using, and what non-standard rc settings are you
using? You must be using either usetex or ps.usedistiller, because
ghostscript is failing to produce a distilled file.

I just fixed a bug in the error report, please update from svn or change line
1333 in backend_ps.py to read:

    if exit_status: raise RuntimeError('pdftops was not able to process your \
image.\nHere is the full report generated by pdftops: \n\n' + fh.read())

My experience has been that ghostscript fails like this when you are using the
usetex option, and your latex syntax is incorrect. Latex may not exit with an
error status, even though it encountered a problem, and the bad output is
propagated downstream to dvips and ghostscript. If you want a more specific
answer, please provide a specific example that produces your result.

Darren

···

On Tuesday 17 October 2006 11:50, Humufr wrote:

did you try to fix the size of the figure and the dpi?

N.

Eric Emsellem wrote:
> Hi,
>
> I have a problem saving eps files in certain conditions. Unfortunately I
> am unable to find a simple example which may be very illustrative here
> to show you when it works and when it does not.
> I include the error message below and so the question is: does anybody
> have a hint of why the savefig fails and crashes?
>
> (I tried to close('all'), rcdefaults, etc).
>
> thanks for any input,
>
> Eric
> =================
>
> >> savefig('toto.eps')
>
> Your figure is too big to fit on a4 paper. b4 paper will be used to
> prevent clipping.
> AFPL Ghostscript 8.51: Unrecoverable error, exit code 1
> -------------------------------------------------------------------------
>-- exceptions.NameError Traceback (most
> recent call last)
>
> /home/science/Sauron/AnalysisKin/Paper7/<ipython console>
>
> /usr/local/lib/python2.4/site-packages/matplotlib/pylab.py in
> savefig(*args, **kwargs)
> 809 def savefig(*args, **kwargs):
> 810 fig = gcf()
> --> 811 return fig.savefig(*args, **kwargs)
> 812 if Figure.savefig.__doc__ is not None:
> 813 savefig.__doc__ = _shift_string(Figure.savefig.__doc__)
>
> /usr/local/lib/python2.4/site-packages/matplotlib/figure.py in
> savefig(self, *args, **kwargs)
> 673 kwargs[key] = rcParams['savefig.%s'%key]
> 674
> --> 675 self.canvas.print_figure(*args, **kwargs)
> 676
> 677 def colorbar(self, mappable, cax=None, **kw):
>
> /usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg
>.py in print_figure(self, filename, dpi, facecolor, edgecolor,
> orientation, **kwargs)
> 112 try:
> 113 agg.print_figure(filename, dpi, facecolor,
> edgecolor,
> --> 114 orientation, **kwargs)
> 115 except IOError, msg:
> 116 error_msg_gtk('Failed to save\nError message:
> %s'%(msg,), self)
>
> /usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py
> in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
> **kwargs)
> 486 ps = self.switch_backends(FigureCanvasPS)
> 487 ps.print_figure(filename, dpi, facecolor,
> edgecolor, --> 488 orientation, **kwargs)
> 489 elif ext.find('pdf')>=0:
> 490 from backend_pdf import FigureCanvasPdf
>
> /usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py
> in print_figure(self, outfile, dpi, facecolor, edgecolor, orientation,
> papertype)
> 999 # Let's keep the usetex stuff seperate from the
> generic postscript
> 1000 self._print_figure_tex(outfile, dpi, facecolor,
> edgecolor,
> -> 1001 orientation, papertype)
> 1002 else:
> 1003 if isinstance(outfile, file):
>
> /usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py
> in _print_figure_tex(self, outfile, dpi, facecolor, edgecolor,
> orientation, papertype)
> 1233 elif rcParams['text.usetex']:
> 1234 if False: pass # for debugging
> -> 1235 else: gs_distill(tmpfile, ext=='.eps',
> ptype=papertype, bbox=bbox)
> 1236
> 1237 if isinstance(outfile, file):
>
> /usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py
> in gs_distill(tmpfile, eps, ptype, bbox)
> 1331 exit_status = os.system(command)
> 1332 fh = file(outfile)
> -> 1333 if exit_status: raise RuntimeError('ghostscript was not able
> to process \
> 1334 your image.\nHere is the full report generated by ghostscript: \
> 1335 \n\n'% dvifile + fh.read())
>
> NameError: global name 'dvifile' is not defined
>
>
> --
> ====================================================================
> Eric Emsellem emsellem@...419...
> Centre de Recherche Astrophysique de Lyon
> 9 av. Charles-Andre tel: +33 (0)4 78 86 83 84
> 69561 Saint-Genis Laval Cedex fax: +33 (0)4 78 86 83 86
> France http://www-obs.univ-lyon1.fr/eric.emsellem
> ====================================================================
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Darren S. Dale, Ph.D.
Staff Scientist
Cornell High Energy Synchrotron Source
Cornell University
275 Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

dd55@...163...
office: (607) 255-3819
fax: (607) 255-9001
http://www.chess.cornell.edu