Steve Schmerler a écrit :
> Nicolas Champavert wrote:
>
>> Hello,
>>
>> I have some problems when trying to save a figure with usetex=True.
>> Sometimes, it is not possible to save the figure when trying to put an
>> xlabel with LaTeX inside.
>> It works with pylab.xlabel('M$_\odot$') but not with
>> pylab.xlabel('10$^3$ M$_\odot$') (see below). Do you know why ?
>>
>>
>
>
> Works fine here, with and w/o raw strings.
>
> In [75]: rcParams['text.usetex']=True
>
> In [76]: plot([1,2,3])
> Out[76]: [<matplotlib.lines.Line2D instance at 0xa0db754c>]
>
> In [77]: xlabel('10$^3$ M$_\odot$')
> Out[77]: <matplotlib.text.Text instance at 0xa0daea2c>
>
> In [78]: savefig('test.eps')
>
> In [79]: matplotlib.__version__
> Out[79]: '0.87.7'
>
> In [80]: matplotlib.__revision__
> Out[80]: '$Revision: 2835 $'
>
>
> Maybe you need to upgrade, but that's just a guess.
>
I had matplotlib revision 2835. I made an upgrade. Now I have revision 2905.
I still have problem but it is very strange:
- when I plot [0,1] with xlabel(r'(10$^3$ M$_\odot$)'), it works.
- when I plot [1,2] with xlabel(r'Upper mass for the IMF (10$^3$
M$_\odot$)'), it works.
- but it doesn't work if I plot [0,1] with xlabel(r'Upper mass for the
IMF (10$^3$ M$_\odot$)')...
In [1]:import matplotlib
In [2]:import pylab
In [3]:matplotlib.__version__
Out[3]:'0.87.7'
In [4]:matplotlib.__revision__
Out[4]:'$Revision: 2905 $'
In [5]:matplotlib.rc('text',usetex=True)
In [6]:pylab.plot([0,1])
Out[6]:[<matplotlib.lines.Line2D instance at 0xb67b7e4c>]
In [7]:pylab.xlabel(r'(10$^3$ M$_\odot$)')
Out[7]:<matplotlib.text.Text instance at 0xb691762c>
In [8]:pylab.savefig('toto1.eps')
In [9]:pylab.close()
In [10]:pylab.plot([1,2])
Out[10]:[<matplotlib.lines.Line2D instance at 0xb67d7fec>]
In [11]:pylab.xlabel(r'Upper mass for the IMF (10$^3$ M$_\odot$)')
Out[11]:<matplotlib.text.Text instance at 0xb67d0c6c>
In [12]:pylab.savefig('toto2.eps')
In [13]:pylab.close()
In [14]:pylab.plot([0,1])
Out[14]:[<matplotlib.lines.Line2D instance at 0xb67f078c>]
In [15]:pylab.xlabel(r'Upper mass for the IMF (10$^3$ M$_\odot$)')
Out[15]:<matplotlib.text.Text instance at 0xb63413ac>
In [16]:pylab.savefig('toto3.eps')
sh: line 1: 19756 Erreur de segmentation gs -dBATCH -dNOPAUSE -r6000
-sDEVICE=pswrite -sPAPERSIZE=letter
-sOutputFile="/tmp/11701f1f88db8c691a0ca6ac520c7706.ps"
"/tmp/11701f1f88db8c691a0ca6ac520c7706"
>"/tmp/11701f1f88db8c691a0ca6ac520c7706.output"
---------------------------------------------------------------------------
exceptions.RuntimeError Traceback (most
recent call last)
/home/champavert/<ipython console>
/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py in
savefig(*args, **kwargs)
811 def savefig(*args, **kwargs):
812 fig = gcf()
--> 813 return fig.savefig(*args, **kwargs)
814 if Figure.savefig.__doc__ is not None:
815 savefig.__doc__ = _shift_string(Figure.savefig.__doc__)
/usr/local/lib/python2.4/site-packages/matplotlib/figure.py in
savefig(self, *args, **kwargs)
685 kwargs[key] = rcParams['savefig.%s'%key]
686
--> 687 self.canvas.print_figure(*args, **kwargs)
688
689 def colorbar(self, mappable, cax=None, **kw):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py
in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
**kwargs)
184 if dpi is None: dpi = rcParams['savefig.dpi']
185 agg = self.switch_backends(FigureCanvasAgg)
--> 186 agg.print_figure(filename, dpi, facecolor, edgecolor,
orientation,
187 **kwargs)
188 self.figure.set_canvas(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)
1009 # Let's keep the usetex stuff seperate from the
generic postscript
1010 self._print_figure_tex(outfile, dpi, facecolor,
edgecolor,
-> 1011 orientation, papertype)
1012 else:
1013 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)
1243 elif rcParams['text.usetex']:
1244 if False: pass # for debugging
-> 1245 else: gs_distill(tmpfile, ext=='.eps',
ptype=papertype, bbox=bbox)
1246
1247 if isinstance(outfile, file):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py
in gs_distill(tmpfile, eps, ptype, bbox)
1341 exit_status = os.system(command)
1342 fh = file(outfile)
-> 1343 if exit_status: raise RuntimeError('ghostscript was not able
to process \
1344 your image.\nHere is the full report generated by
ghostscript:\n\n' + fh.read())
1345 else: verbose.report(fh.read(), 'debug')
RuntimeError: ghostscript was not able to process your image.
Here is the full report generated by ghostscript:
ESP Ghostscript 8.15 (2006-04-19)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file COPYING for details.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users