SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S





1
(10)
2
(3)
3
(5)
4
(7)
5
(18)
6
(4)
7
(15)
8
(7)
9
(10)
10
(4)
11
(18)
12
(15)
13
(11)
14
(11)
15
(4)
16
(28)
17
(17)
18
(22)
19
(12)
20
(19)
21
(17)
22
(14)
23
(4)
24
(3)
25
(6)
26
(8)
27
(13)
28
(11)
29
(21)
30
(3)
31
(5)






Showing 15 results of 15

In article <E87...@cs...>,
 belinda thom <bt...@cs...> wrote:
> Hi again,
> 
> At http://matplotlib.sourceforge.net/installing.html under topic OS X:
> 
> "All of the backends run on OS X. Chris Barker has built a binary 
> package (fink users see below) for matplotlib which is hosted on 
> pythonmac, and works with Agg, Wx and Tk; see the step-by-step 
> instructions kindly provided by Michael Tobis."
> 
> note that the step-by-step link leads to:
> 
> Under revision. Please come back soon.
That is indeed outdated (Charlie Moad has done most of the recent binary 
builds, though I got in first on a few). One source of "how to build" is:
Building Matplotlib for MacOS 
<http://www.astro.washington.edu/rowen/BuildingMatplotlibForMac.html>
-- Russell
From: Eric F. <ef...@ha...> - 2006年12月11日 18:30:48
Robert Cimrman wrote:
[...]
> What could be done, though, is to raise an exception explaining that 
> sparse matrices and the image mode don't like each other; as it is, the 
> function spy3 just dies on asarray (should be st. like asarray( 
> Z.todense() ))
(I think it would be Z.toarray().)
Good point. Alternatives would be to automatically switch it to plot 
mode, with a warning, or to automatically convert it. Probably the 
former is the better of these two, and maybe your originally suggested 
exception is best of all. What do you think?
Eric
From: Eric F. <ef...@ha...> - 2006年12月11日 18:05:04
Yannick Copin wrote:
> Hi,
> 
> Eric Firing wrote:
>>> from pylab import *
>>> X, Y = meshgrid(linspace(-3,3,11),linspace(-3,3,11))
>>> Z = randn(*X.shape)
>>> lev = linspace(Z.min(),Z.max(),11)[1:-1]
>>> contourf(X,Y,Z, lev, extend='both')
>>> contour(X,Y,Z, lev, colors='k')
>>> show()
>>
>> Now, you may be wondering why we can't simply use the boundary of the 
>> filled regions for the lines as well, to guarantee they are the same. 
>> The reason is that filled contour boundaries include cuts connecting 
>> inner and outer contours, and also inner boundaries (edges of masked 
>> regions--except when affected by a bug) and the outer boundaries of 
>> the domain). It might be possible to simply exclude those line 
>> segments from the line contours, but it is not clear to me that the 
>> effort would be well-spent.
> 
> OK, thanks for the explanations. I was using this dual approach 
> contourf+contour to emphasize the contours from contourf. So is there a 
> direct way to set the linewidth and linecolor (and linestyle?) of 
> contours from contourf? (I suspect not, according to contourf 
> documentation:
> 
> contourf differs from the Matlab (TM) version in that it does not
> draw the polygon edges, because the contouring engine yields
> simply connected regions with branch cuts. To draw the edges,
> add line contours with calls to contour.
> 
> )
> 
You could turn on coloring of the edges, but I don't think you would 
like the result because the edges would include the boundary lines and 
the cut lines.
The ContourSet object returned by contour and contourf has a 
.collections attribute. For contourf it is a list of PolyCollections, 
and you can set their attributes.
>> I think that the differences illustrated in your example will occur 
>> almost entirely in pathologically ambiguous cases, but it is also 
> 
> Not necessarily pathological cases, just noisy data :-/ (I agree my 
> randn-based example was a bit extreme!)
You might be able to avoid the problem most of the time by using some 
gridding routine, preferably something that uses a bit of curvature, to 
double the number of points in each dimension. I haven't tried it, but 
I suspect that this would turn even a very noisy field into something 
that would be contoured the same by contour and contourf.
> 
> Cheers.
From: Nicolas C. <nic...@ob...> - 2006年12月11日 16:01:25
Steve Schmerler a =E9crit :
> Darren Dale wrote:
> =20
>> On Monday 11 December 2006 09:59, Nicolas Champavert wrote:
>> =20
>>> Steve Schmerler a =E9crit :
>>> =20
>>>> Nicolas Champavert wrote:
>>>> =20
>>>>> Hello,
>>>>>
>>>>> I have some problems when trying to save a figure with usetex=3DT=
rue.
>>>>> 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 ?
>>>>> =20
>>>> Works fine here, with and w/o raw strings.
>>>> =20
>> [...]
>> =20
>>> I had matplotlib revision 2835. I made an upgrade. Now I have revisio=
n
>>> 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 th=
e
>>> IMF (10$^3$ M$_\odot$)')...
>>> =20
>> It sounds like an issue with one of the dependencies, probably ghostsc=
ript. I=20
>> have matplotlib-0.87.7, svn revision 2905, and gpl-ghostscript-8.54. I=
 can=20
>> not reproduce the problem here.
>>
>> =20
>
> I seem to be running ESP Ghostscript 8.15.3 (this is what 'gs --version=
'=20
> and 'apt-cache show gs' tell me). All the examples work fine here ...
>
> =20
I had Ghostscript 8.15.3 too. I have made an update to ghostscript 8.54=20
and now it works.
Nicolas
From: Steve S. <el...@gm...> - 2006年12月11日 15:46:14
Darren Dale wrote:
> On Monday 11 December 2006 09:59, Nicolas Champavert wrote:
>> 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.
> [...]
>> 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$)')...
> 
> It sounds like an issue with one of the dependencies, probably ghostscript. I 
> have matplotlib-0.87.7, svn revision 2905, and gpl-ghostscript-8.54. I can 
> not reproduce the problem here.
> 
I seem to be running ESP Ghostscript 8.15.3 (this is what 'gs --version' 
and 'apt-cache show gs' tell me). All the examples work fine here ...
-- 
cheers,
steve
Random number generation is the art of producing pure gibberish as 
quickly as possible.
From: Darren D. <dd...@co...> - 2006年12月11日 15:16:14
On Monday 11 December 2006 09:59, Nicolas Champavert wrote:
> Steve Schmerler a =E9crit :
> > Nicolas Champavert wrote:
> >> Hello,
> >>
> >> I have some problems when trying to save a figure with usetex=3DTrue.
> >> 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.
[...]
>
> 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$)')...
It sounds like an issue with one of the dependencies, probably ghostscript.=
 I=20
have matplotlib-0.87.7, svn revision 2905, and gpl-ghostscript-8.54. I can=
=20
not reproduce the problem here.
Darren
From: Nicolas C. <nic...@ob...> - 2006年12月11日 15:09:31
No the '\' is not the problem. \odot is a LaTeX command. I still have=20
the problem if I don't use it (see below with only pylab.xlabel(r'Upper=20
mass for the IMF (10$^3$)')) and \\odot writes 'odot' and doesn't write=20
the 'odot' symbol.
Gary Ruben a =E9crit :
> I haven't tried it, but my guess is the '\' character is the problem.
>
> > pylab.xlabel('10$^3$ M$_\odot$')
>
> Try
> pylab.xlabel(r'10$^3$ M$_\odot$')
> ^
> Add raw string marker.
>
> or maybe
> pylab.xlabel('10$^3$ M$_\\odot$')
>
> Gary R.
>
> Nicolas Champavert wrote:
>> Hello,
>>
>> I have some problems when trying to save a figure with usetex=3DTrue=
.=20
>> Sometimes, it is not possible to save the figure when trying to put=20
>> an xlabel with LaTeX inside.
>> It works with pylab.xlabel('M$_\odot$') but not with=20
>> pylab.xlabel('10$^3$ M$_\odot$') (see below). Do you know why ?
>
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=3DTrue)
In [6]:pylab.plot([0,1])
Out[6]:[<matplotlib.lines.Line2D instance at 0xb67dde4c>]
In [7]:pylab.xlabel(r'Upper mass for the IMF (10$^3$)')
Out[7]:<matplotlib.text.Text instance at 0xb693d62c>
In [8]:pylab.savefig('test.eps')
sh: line 1: 19944 Erreur de segmentation gs -dBATCH -dNOPAUSE -r6000=20
-sDEVICE=3Dpswrite -sPAPERSIZE=3Dletter=20
-sOutputFile=3D"/tmp/098f6bcd4621d373cade4e832627b4f6.ps"=20
"/tmp/098f6bcd4621d373cade4e832627b4f6"=20
 >"/tmp/098f6bcd4621d373cade4e832627b4f6.output"
-------------------------------------------------------------------------=
--
exceptions.RuntimeError Traceback (most=20
recent call last)
/home/champavert/<ipython console>
/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py in=20
savefig(*args, **kwargs)
 811 def savefig(*args, **kwargs):
 812 fig =3D gcf()
--> 813 return fig.savefig(*args, **kwargs)
 814 if Figure.savefig.__doc__ is not None:
 815 savefig.__doc__ =3D _shift_string(Figure.savefig.__doc__)
/usr/local/lib/python2.4/site-packages/matplotlib/figure.py in=20
savefig(self, *args, **kwargs)
 685 kwargs[key] =3D rcParams['savefig.%s'%key]
 686
--> 687 self.canvas.print_figure(*args, **kwargs)
 688
 689 def colorbar(self, mappable, cax=3DNone, **kw):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.=
py=20
in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,=20
**kwargs)
 184 if dpi is None: dpi =3D rcParams['savefig.dpi']
 185 agg =3D self.switch_backends(FigureCanvasAgg)
--> 186 agg.print_figure(filename, dpi, facecolor, edgecolor,=20
orientation,
 187 **kwargs)
 188 self.figure.set_canvas(self)
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py=
=20
in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,=20
**kwargs)
 486 ps =3D self.switch_backends(FigureCanvasPS)
 487 ps.print_figure(filename, dpi, facecolor, edgecol=
or,
--> 488 orientation, **kwargs)
 489 elif ext.find('pdf')>=3D0:
 490 from backend_pdf import FigureCanvasPdf
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py=20
in print_figure(self, outfile, dpi, facecolor, edgecolor, orientation,=20
papertype)
 1009 # Let's keep the usetex stuff seperate from the=20
generic postscript
 1010 self._print_figure_tex(outfile, dpi, facecolor,=20
edgecolor,
-> 1011 orientation, papertype)
 1012 else:
 1013 if isinstance(outfile, file):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py=20
in _print_figure_tex(self, outfile, dpi, facecolor, edgecolor,=20
orientation, papertype)
 1243 elif rcParams['text.usetex']:
 1244 if False: pass # for debugging
-> 1245 else: gs_distill(tmpfile, ext=3D=3D'.eps',=20
ptype=3Dpapertype, bbox=3Dbbox)
 1246
 1247 if isinstance(outfile, file):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py=20
in gs_distill(tmpfile, eps, ptype, bbox)
 1341 exit_status =3D os.system(command)
 1342 fh =3D file(outfile)
-> 1343 if exit_status: raise RuntimeError('ghostscript was not able=20
to process \
 1344 your image.\nHere is the full report generated by=20
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.
From: Nicolas C. <nic...@ob...> - 2006年12月11日 14:59:29
Steve Schmerler a =E9crit :
> Nicolas Champavert wrote:
> =20
>> Hello,
>>
>> I have some problems when trying to save a figure with usetex=3DTrue=
.=20
>> Sometimes, it is not possible to save the figure when trying to put an=
=20
>> xlabel with LaTeX inside.
>> It works with pylab.xlabel('M$_\odot$') but not with=20
>> pylab.xlabel('10$^3$ M$_\odot$') (see below). Do you know why ?
>>
>> =20
>
>
> Works fine here, with and w/o raw strings.
>
> In [75]: rcParams['text.usetex']=3DTrue
>
> 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.
> =20
I had matplotlib revision 2835. I made an upgrade. Now I have revision 29=
05.
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$=20
M$_\odot$)'), it works.
- but it doesn't work if I plot [0,1] with xlabel(r'Upper mass for the=20
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=3DTrue)
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=20
-sDEVICE=3Dpswrite -sPAPERSIZE=3Dletter=20
-sOutputFile=3D"/tmp/11701f1f88db8c691a0ca6ac520c7706.ps"=20
"/tmp/11701f1f88db8c691a0ca6ac520c7706"=20
 >"/tmp/11701f1f88db8c691a0ca6ac520c7706.output"
-------------------------------------------------------------------------=
--
exceptions.RuntimeError Traceback (most=20
recent call last)
/home/champavert/<ipython console>
/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py in=20
savefig(*args, **kwargs)
 811 def savefig(*args, **kwargs):
 812 fig =3D gcf()
--> 813 return fig.savefig(*args, **kwargs)
 814 if Figure.savefig.__doc__ is not None:
 815 savefig.__doc__ =3D _shift_string(Figure.savefig.__doc__)
/usr/local/lib/python2.4/site-packages/matplotlib/figure.py in=20
savefig(self, *args, **kwargs)
 685 kwargs[key] =3D rcParams['savefig.%s'%key]
 686
--> 687 self.canvas.print_figure(*args, **kwargs)
 688
 689 def colorbar(self, mappable, cax=3DNone, **kw):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.=
py=20
in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,=20
**kwargs)
 184 if dpi is None: dpi =3D rcParams['savefig.dpi']
 185 agg =3D self.switch_backends(FigureCanvasAgg)
--> 186 agg.print_figure(filename, dpi, facecolor, edgecolor,=20
orientation,
 187 **kwargs)
 188 self.figure.set_canvas(self)
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py=
=20
in print_figure(self, filename, dpi, facecolor, edgecolor, orientation,=20
**kwargs)
 486 ps =3D self.switch_backends(FigureCanvasPS)
 487 ps.print_figure(filename, dpi, facecolor, edgecol=
or,
--> 488 orientation, **kwargs)
 489 elif ext.find('pdf')>=3D0:
 490 from backend_pdf import FigureCanvasPdf
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py=20
in print_figure(self, outfile, dpi, facecolor, edgecolor, orientation,=20
papertype)
 1009 # Let's keep the usetex stuff seperate from the=20
generic postscript
 1010 self._print_figure_tex(outfile, dpi, facecolor,=20
edgecolor,
-> 1011 orientation, papertype)
 1012 else:
 1013 if isinstance(outfile, file):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py=20
in _print_figure_tex(self, outfile, dpi, facecolor, edgecolor,=20
orientation, papertype)
 1243 elif rcParams['text.usetex']:
 1244 if False: pass # for debugging
-> 1245 else: gs_distill(tmpfile, ext=3D=3D'.eps',=20
ptype=3Dpapertype, bbox=3Dbbox)
 1246
 1247 if isinstance(outfile, file):
/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_ps.py=20
in gs_distill(tmpfile, eps, ptype, bbox)
 1341 exit_status =3D os.system(command)
 1342 fh =3D file(outfile)
-> 1343 if exit_status: raise RuntimeError('ghostscript was not able=20
to process \
 1344 your image.\nHere is the full report generated by=20
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.
From: Steve S. <el...@gm...> - 2006年12月11日 13:02:16
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.
-- 
cheers,
steve
Random number generation is the art of producing pure gibberish as
quickly as possible.
From: Gary R. <gr...@bi...> - 2006年12月11日 12:55:55
I haven't tried it, but my guess is the '\' character is the problem.
> pylab.xlabel('10$^3$ M$_\odot$')
Try
pylab.xlabel(r'10$^3$ M$_\odot$')
 ^
 Add raw string marker.
or maybe
pylab.xlabel('10$^3$ M$_\\odot$')
Gary R.
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 ?
From: Darren D. <dd...@co...> - 2006年12月11日 12:54:05
On Monday 11 December 2006 7:12 am, 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 ?
You're example works on my system. But note, you should use raw strings, maybe 
that is the source of your problem:
pylab.xlabel(r'10$^3$ M$_\odot$')
From: Nicolas C. <nic...@ob...> - 2006年12月11日 12:12:32
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 ?
In [1]:import matplotlib
In [2]:matplotlib.__version__
Out[2]:'0.87.7'
In [3]:import pylab
In [4]:a=[0,1]
In [5]:pylab.plot(a)
Out[5]:[<matplotlib.lines.Line2D instance at 0xb690472c>]
In [6]:pylab.xlabel('M$_\odot$')
Out[6]:<matplotlib.text.Text instance at 0xb6976d2c>
In [7]:pylab.savefig('toto.eps')
In [8]:matplotlib.rc('text',usetex=True)
In [9]:pylab.plot(a)
Out[9]:[<matplotlib.lines.Line2D instance at 0xb692466c>]
In [10]:pylab.xlabel('M$_\odot$')
Out[10]:<matplotlib.text.Text instance at 0xb6916e2c>
In [11]:pylab.savefig('toto.eps')
In [12]:matplotlib.rc('text',usetex=False)
In [13]:pylab.plot(a)
Out[13]:[<matplotlib.lines.Line2D instance at 0xb655cb8c>]
In [14]:pylab.xlabel('10$^3$ M$_\odot$')
Out[14]:<matplotlib.text.Text instance at 0xb65586ac>
In [15]:pylab.savefig('toto.eps')
In [16]:matplotlib.rc('text',usetex=True)
In [17]:pylab.plot(a)
Out[17]:[<matplotlib.lines.Line2D instance at 0xb657286c>]
In [18]:pylab.xlabel('10$^3$ M$_\odot$')
Out[18]:<matplotlib.text.Text instance at 0xb656af6c>
In [19]:pylab.savefig('toto.eps')
sh: line 1: 16796 Erreur de segmentation gs -dBATCH -dNOPAUSE -r6000 
-sDEVICE=pswrite -sPAPERSIZE=letter 
-sOutputFile="/tmp/f71dbe52628a3f83a77ab494817525c6.ps" 
"/tmp/f71dbe52628a3f83a77ab494817525c6" 
 >"/tmp/f71dbe52628a3f83a77ab494817525c6.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)
 812 def savefig(*args, **kwargs):
 813 fig = gcf()
--> 814 return fig.savefig(*args, **kwargs)
 815 if Figure.savefig.__doc__ is not None:
 816 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.
Nicolas
From: Robert C. <cim...@nt...> - 2006年12月11日 09:44:27
Eric Firing wrote:
> Robert Cimrman wrote:
>> Eric Firing wrote:
>>> Robert and any other spy users:
>>>
>>> I have committed to svn a new axes method, spy3, that combines a 
>>> modification of the functionality of both spy and spy2. I hope you 
>>> can check it out. If it looks OK, then I would like to simply 
>>> replace spy and spy2 with this combined version. In that case the 
>>> pylab interface, which now gives access to spy and spy2, would have a 
>>> single spy function which would access the new version. My suspicion 
>>> is that spy is used almost entirely in interactive mode, and probably 
>>> not by very many people, so that this changeover can be made quickly 
>>> with little disruption to present users.
>>>
>>> Attached is a script illustrating the difference in the way spy3 
>>> displays a matrix (it matches the way it is printed: first index is 
>>> row number, second is column number, row number increases down) 
>>> versus what spy and spy2 do (first index is X, second index is Y).
>>>
>>> Also attached is the diff for spy3.
>>>
>>> Users may want to comment in particular on the default for the 
>>> "aspect" kwarg. Presently it is set to "equal" so that the shape of 
>>> the plot is the shape of the array with square cells. This differs 
>>> from spy and spy2. The rationale is that it gives the best picture 
>>> of what the array looks like, including its shape.
>>
>> Thumbs up :), just add the sparse-full matrix switch to the imshow 
>> branch too, if possible. But I am happy with it as it is.
 >
> The sparse-full difference only works with the plot mode; for an image 
> there is no alternative to providing a value for every pixel, so I don't 
> know of any way to optimize it for the case of sparse storage. A 
> polygon collection could be used to achieve the same result in this 
> case. I'm not sure it is a good idea, though, because there would be an 
> advantage of not converting to a regular array only in the case where 
> the array is so large that such a conversion would use a big chunk of 
> memory, and in that case the polygons probably would be less than 
> single-pixel size anyway, so one would be better off using the present 
> symbol-plotting mode.
Yeah, I have tried to write it myself before I posted this message but 
found that it probably would not work well - nevertheless I asked :).
What could be done, though, is to raise an exception explaining that 
sparse matrices and the image mode don't like each other; as it is, the 
function spy3 just dies on asarray (should be st. like asarray( 
Z.todense() ))
In [1]:import numpy as nm
In [2]:import scipy.sparse as sp
In [3]:a = nm.array( [[0, 1], [0,1], [2,3]] )
In [4]:b = sp.csr_matrix( a )
In [5]:gca().spy3( b )
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most 
recent call last)
/home/eldaran/<console>
/usr/lib/python2.4/site-packages/matplotlib/axes.py in spy3(self, Z, 
precision, marker, markersize, aspect, **kwargs)
 4377 """
 4378 if marker is None and markersize is None:
-> 4379 Z = asarray(Z)
 4380 if precision is None: mask = Z!=0.
 4381 else: mask = absolute(Z)>precision
/usr/lib/python2.4/site-packages/numarray/numarraycore.py in 
asarray(seq, type, typecode, dtype)
 432 if isinstance(seq, _gen.NDArray) and type is None and 
typecode is None:
 433 return seq
--> 434 return array(seq, type=type, typecode=typecode, copy=0, 
dtype=dtype)
 435
 436 inputarray = asarray # Obsolete synonym
/usr/lib/python2.4/site-packages/numarray/numarraycore.py in 
array(sequence, typecode, copy, savespace, type, shape, dtype)
 415 if (hasattr(sequence,'__getitem__')
 416 and hasattr(sequence,'__len__')):
--> 417 return fromlist(sequence,type,shape)
 418
 419 ##SEQUENCE is a scalar or unhandleable
/usr/lib/python2.4/site-packages/numarray/numarraycore.py in 
fromlist(seq, type, shape, check_overflow, typecode, dtype)
 246 return arr
 247
--> 248 if not len(seq) and type is None:
 249 type = _nt.Long
 250
/home/share/software/usr/lib/python2.4/site-packages/scipy/sparse/sparse.py 
in __len__(self)
 163 def __len__(self):
 164 # return self.getnnz()
--> 165 raise TypeError, "sparse matrix length is ambiguous; use 
getnnz()" \
 166 " or shape[0]"
 167
> Anyway, I'm glad it works for you. Thanks for checking.
Thanks for your fast help!
r.
From: Pierre GM <pgm...@gm...> - 2006年12月11日 03:03:29
On Sunday 10 December 2006 21:14, Chuang wrote:
> Hi there,
>
> I wanna plot two curves, and save to 2 different files. However, when I
> used the following code, the 2nd file contains both the 2 curves.
>
> plot(X1,Y1)
> savefig('file1.png')
> plot(X2,Y2)
> savefig('file2.png')
>
> It seems like the program memorize both of the two curves and save to
> the 2nd file. How can I save only the 2nd curve in the 2nd file?
Possibility #1: Create a new figure before the second plot
>>>plot(x1,y1)
>>>figure()
>>>plot(x2,y2)
Possibility #2: Clear the figure before the second plot 
>>>plot(x1,y1)
>>>clf()
>>>plot(x2,y2)
Possibility #3: Force the current axes to refresh, by setting its "hold" 
property to "False"
>>>plot(x1,y1)
>>>gca().hold(False)
>>>plot(x2,y2)
Possibiltiy #4: Get familiar with the more pythonesque functions.
From: Chuang <chu...@gm...> - 2006年12月11日 02:14:39
Hi there,
I wanna plot two curves, and save to 2 different files. However, when I
used the following code, the 2nd file contains both the 2 curves.
plot(X1,Y1)
savefig('file1.png')
plot(X2,Y2)
savefig('file2.png')
It seems like the program memorize both of the two curves and save to
the 2nd file. How can I save only the 2nd curve in the 2nd file? 
Thanks,
CC
3 messages has been excluded from this view by a project administrator.

Showing 15 results of 15

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /