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
(35)
2
(15)
3
(16)
4
(3)
5
(1)
6
(1)
7
(11)
8
(10)
9
(13)
10
(24)
11
(21)
12
(10)
13
(2)
14
(24)
15
(20)
16
(36)
17
(13)
18
(6)
19
(4)
20
(2)
21
(11)
22
(13)
23
(7)
24
(10)
25
(7)
26
(12)
27
(2)
28
(6)
29
(20)
30
(9)
31
(39)


Showing 24 results of 24

From: KURT P. <pet...@ms...> - 2008年07月10日 23:45:12
I am trying to do something similar to the plot_tissot.py example, but am 
having some problems.
 I would like to project a group of circles onto a map projection. Below 
is the code I developed, which doesn't work because I get the error:
==========ERROR ====
 File "C:\Python25\Lib\site-packages\matplotlib\path.py", line 127, in 
__init__
 assert vertices.ndim == 2
AssertionError
==========
====CODE =========
m = Basemap(llcrnrlon=-180,llcrnrlat=-80,urcrnrlon=180,urcrnrlat=80, 
projection='cyl')
shp_info = m.readshapefile(r'C:\Documents and Settings\kpeters\My 
Documents\basemap-0.99\examples\tissot','tissot',drawbounds=True)
ax = plt.gca()
coords = 
[(116,45),(104,41),(98,37),(88,30),(78,25),(116,-45),(104,-41),(98,-37),(88,-30),(78,-25)]
for lon1,lat1 in coords:
 newverts = []
 circle = Circle((lon1,lat1),radius=10, facecolor='green')
# trans = circle.get_patch_transform()
 path = circle.get_path()
 #for jj in path.iter_segments(): #looks like the iterator is broken???
 for jj in path.vertices:
 verts1, verts2 = jj;
 newverts.append(m(verts1,verts2))
 print newverts
 p = PolyCollection(newverts, facecolor='green', zorder = 10)
 ax.add_collection(p)
==END CODE==
Is this a logical/best way to get circles properly projected, or is there a 
better way?
I looked at "transform_vector" but I'm not too sure what the uin and vin do. 
 Is there a transform in basemaps that could be passed to a path like in 
this thread: "Re: [Matplotlib-users] Drawing filled circles (discs)":
"circle = CirclePolygon((x1,y1), r, resolution)
trans = circle.get_patch_transform()
path = circle.get_path()
transpath = path.transformed(trans)"
It should be noted that I also tried:
===code dif===
for lon1,lat1 in coords:
 newverts = []
 circle = Circle((lon1,lat1),radius=10, facecolor='green')
 path = circle.get_path()
 #for jj in path.iter_segments(): #looks like the iterator is broken???
 for jj in path.vertices:
 verts1, verts2 = jj;
 newverts.append(m(verts1,verts2))
 print newverts
# newcircle = Circle(m(lon1,lat1),radius=10, facecolor='green')
 p = Polygon(newverts, facecolor='green', zorder = 10)
 ax.add_patch(p)
===========
but that doesn't seem to display anything (I suspect the right radius isn't 
being used). Note, that the "newcircle" line that is commented out, puts 
circles on the map, they're just not transformed right.
Regards,
Kurt
From: Robin <ro...@gm...> - 2008年07月10日 22:58:39
Attachments: bad_legend.pdf
Hi,
I have a problem with legends where the vertical spacing is sometimes
a bit funny (lines don't seem to be evenly spaced).
I am now preparing some figures for publication and this is the last
niggle I'd really like to resolve.
Is there anything I could do to fix this?
A small example is attached (I cropped it to just the legend to reduce
file size).
I am setting the label on the bars I am plotting and then just calling
ax.legend()
At the risk of putting two queries in one email the only other problem
I have regularly is that small figures resize themselves when the
mouse rolls over them. I am using TkAgg backend on OS X but I think it
happens on other platforms as well. On mouse over the window jiggles
and resizes slightly. When I am saving figures I have to be careful to
call savefig from the command line without touching the window with
the mouse to ensure they save as the correct size. Just wondered if it
was a known issue...
Apart from these minor things though matplotlib has been performing great!
Thanks,
Robin
From: Neil P. <ne...@ke...> - 2008年07月10日 19:28:24
Hi,
I'm not a regular 0.98 user right now (using debian stable 0.91 or 
similar in a python app) but was investigating the new documentation at 
http://matplotlib.sourceforge.net/doc/html/index.html and noticed a few 
things (typos?) which I wanted to check. It does look good - ReST?
- in artists.html, an 'ax' variable is first created, then after 
"Continuing with our example:" the plot command is run on 'ax1' (bug/typo?)
- just after this, there is "it creates a Line2D instance and adds it 
the the Axes.lines list." (typo? 'to the'?)
Lastly, has anyone checked whether 0.98 still has the 'down key' bug for 
key-press events? (is there a bugzilla/tracker?)
Thanks,
-- 
Neil Pilgrim
From: Darren D. <dsd...@gm...> - 2008年07月10日 15:52:49
Hi David,
On Thursday 10 July 2008 11:15:37 am David M. Kaplan wrote:
> 2) I have noticed that the font used for the xticklabels and the font
> used for the xlabel and contour labels appears to be different (example
> attached). One appears to be serif and the other sans-serif. This
> seems to be due to using tex for text rendering. I am not sure if this
> also occurred before the update, but I didn't notice it previously.
It has always been this way. We tried a workaround once a couple years back 
and it turned into a real mess.
> Looking at the properties of the different text objects, it isn't
> apparent that there should be a difference - both have font properties
> that indicate sans-serif, but the text of tick labels appears to be
> surrounded by $'s forcing it through the text parser, while that of the
> contour labels is not. Is this difference normal or expected? Is there
> a way around this? In particular, I would like to use sans-serif for
> everything - is this possible while still using tex?
I think there is a package, sansmath or something like that, that will allow 
latex to use sans-serif fonts in math mode. You could try adding it to the 
text.latex.preamble rc setting, but that option is not officially supported.
If you don't like the limitations of latex, you might want to turning off 
usetex and just use matplotlibs mathtext, which recently got a significant 
rewrite and is now quite capable thanks to Mike Droettboom. Here's some 
documentation too:
http://matplotlib.sourceforge.net/doc/html/users/mathtext.html
Darren
From: Michael D. <md...@st...> - 2008年07月10日 15:44:14
David M. Kaplan wrote:
> Hi,
>
> I just upgraded to matplotlib 0.98.1 on a ubuntu hardy heron system. I
> have noticed two problems since the upgrade:
>
> 1) For any plot, if I try to look at the properties of a text object I
> get an error related to FontProperties having no attribute 'items'. See
> below:
>
> In [1]: plot(range(10))
> Out[1]: [<matplotlib.lines.Line2D object at 0x924f9ac>]
>
> In [2]: xlh=get(gca(),'xticklabels')
>
> In [3]: get(xlh[0])
> ------------------------------------------------------------
> Traceback (most recent call last):
> File "<ipython console>", line 1, in <module>
> File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line
> 724, in get
> return getp(o, *args, **kwargs)
> File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line
> 716, in getp
> print '\n'.join(insp.pprint_getters())
> File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line
> 684, in pprint_getters
> s = str(val)
> File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
> line 681, in __str__
> return self.get_fontconfig_pattern()
> File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
> line 737, in get_fontconfig_pattern
> return generate_fontconfig_pattern(self)
> File
> "/usr/lib/python2.5/site-packages/matplotlib/fontconfig_pattern.py",
> line 164, in generate_fontconfig_pattern
> for key, val in d.items():
> <type 'exceptions.AttributeError'>: 'FontProperties' object has no
> attribute 'items'
> 
Thanks for the report. This is a bug and should now be fixed in SVN.
> 2) I have noticed that the font used for the xticklabels and the font
> used for the xlabel and contour labels appears to be different (example
> attached). One appears to be serif and the other sans-serif. This
> seems to be due to using tex for text rendering. I am not sure if this
> also occurred before the update, but I didn't notice it previously.
> Looking at the properties of the different text objects, it isn't
> apparent that there should be a difference - both have font properties
> that indicate sans-serif, but the text of tick labels appears to be
> surrounded by $'s forcing it through the text parser, while that of the
> contour labels is not. Is this difference normal or expected? Is there
> a way around this? In particular, I would like to use sans-serif for
> everything - is this possible while still using tex?
> 
To clarify -- you've set the rcParam "text.usetex" to True?
If the tick labels are in fact surrounded by $'s, then, yes, TeX will 
render then in a serif font. This is the default behavior of TeX (math 
is in a serif font) -- though there might be a special package you could 
add to the preamble (the rcParam text.latex.preamble) to change this, 
but that's more of a (La)TeX issue.
Looking at the revision history, it looks like putting $'s around tick 
labels has been done since at least 0.90.1.
Perhaps one of the usetex developers/users has more insight into this 
than I do.
Cheers,
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
On Thursday 10 July 2008 10:48:01 am you wrote:
> Hi Darren,
>
> I have tried rerunning our code with the change you suggested in the
> make_dvi and make_png functions. I am still noticing failures however. I
> put these at the bottom of this message. Strangely enough, these errors
> don't seem to occur when there are a lot of files in my tex.cache
> directory. For example, I ran the code (consisting of ~40 codes all making
> ~10-20 plots each), successfully 3 times (the OSError wasn't raised at all,
> I used a print statement to check). I realised after this that a lot of
> temp files were in my tex.cache directory, so I emptied it and then I
> noticed that a lot of failures occured when I ran the code the next time
> (the OSError I showed previously was raised as well as the error messages
> shown below). It seems weird that it should run fine when a lot of files
> are left in my temp directory and not when it is empty?
Most of those files are not temporary files, but cached files. The error you 
reported only occurs when a required file does not already exist in the 
cache, and like you said, it appears to be the case that two jobs are trying 
to add the same file to the cache at the same time, and one job is failing 
because the other deletes a temporary file that is being used by both. I 
guess.
> Here are the error messages that are occuring now:
>
> Traceback (most recent call last):
> File
> "/home/spxiwh/ihope/852450000-852700000/nsbhinj_summary_plots/../executable
>s/plotinspmissed", line 625, in ?
> savePlot( opts, filename, titleText)
> File
> "/home/spxiwh/ihope/852450000-852700000/nsbhinj_summary_plots/../executable
>s/plotinspmissed", line 108, in savePlot
> dpi_thumb=opts.figure_resolution)
> File
> "/home/spxiwh/lscsoft/executables/cbc_s5_1yr_20070129/pylal//lib64/python2.
>4/site-packages/pylal/InspiralUtils.py", line 54, in savefig_pylal
> fig.savefig(filename, dpi=dpi)
> File "/home/spxiwh/test/matplotlib/figure.py", line 682, in savefig
> self.canvas.print_figure(*args, **kwargs)
> File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 456, in
> print_figure
> self.draw()
> File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 392, in
> draw
> self.figure.draw(renderer)
> File "/home/spxiwh/test/matplotlib/figure.py", line 544, in draw
> for a in self.axes: a.draw(renderer)
> File "/home/spxiwh/test/matplotlib/axes.py", line 1063, in draw
> a.draw(renderer)
> File "/home/spxiwh/test/matplotlib/axis.py", line 595, in draw
> self.label.draw(renderer)
> File "/home/spxiwh/test/matplotlib/text.py", line 340, in draw
> bbox, info = self._get_layout(renderer)
> File "/home/spxiwh/test/matplotlib/text.py", line 187, in _get_layout
> w,h = renderer.get_text_width_height(
> File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 240, in
> get_text_width_height
> Z = texmanager.get_rgba(s, size, self.dpi.get(), rgb)
> File "/home/spxiwh/test/matplotlib/texmanager.py", line 334, in get_rgba
> pngfile = self.make_png(tex, fontsize, dpi, force=False)
> File "/home/spxiwh/test/matplotlib/texmanager.py", line 255, in make_png
> fh = file(outfile)
> IOError: [Errno 2] No such file or directory:
> '/home/spxiwh/.matplotlib/tex.cache/fb2014e54961855bd04020b61190867c.output
>'
That doesnt make any sense to me. file defaults to open a file in append mode, 
it doesnt matter if a file exists or not. Maybe you could try to figure out 
why that fails and report back. 
> And once I noticed:
>
> Traceback (most recent call last):
> File
> "/home/spxiwh/ihope/852450000-852700000/allinj_summary_plots/../executables
>/plotinspmissed", line 661, in ?
> dpi_thumb=opts.figure_resolution)
> File
> "/home/spxiwh/lscsoft/executables/cbc_s5_1yr_20070129/pylal//lib64/python2.
>4/site-packages/pylal/InspiralUtils.py", line 54, in savefig_pylal
> fig.savefig(filename, dpi=dpi)
> File "/usr/lib64/python2.4/site-packages/matplotlib/figure.py", line 682,
> in savefig
> self.canvas.print_figure(*args, **kwargs)
> File
> "/usr/lib64/python2.4/site-packages/matplotlib/backends/backend_agg.py",
> line 456, in print_figure
> self.draw()
> File
> "/usr/lib64/python2.4/site-packages/matplotlib/backends/backend_agg.py",
> line 392, in draw
> self.figure.draw(renderer)
> File "/usr/lib64/python2.4/site-packages/matplotlib/figure.py", line 544,
> in draw
> for a in self.axes: a.draw(renderer)
> File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 1063,
> in draw
> a.draw(renderer)
> File "/usr/lib64/python2.4/site-packages/matplotlib/text.py", line 340,
> in draw
> bbox, info = self._get_layout(renderer)
> File "/usr/lib64/python2.4/site-packages/matplotlib/text.py", line 187,
> in _get_layout
> w,h = renderer.get_text_width_height(
> File
> "/usr/lib64/python2.4/site-packages/matplotlib/backends/backend_agg.py",
> line 240, in get_text_width_height
> Z = texmanager.get_rgba(s, size, self.dpi.get(), rgb)
> File "/usr/lib64/python2.4/site-packages/matplotlib/texmanager.py", line
> 330, in get_rgba
> X = readpng(os.path.join(self.texcache, pngfile))
> RuntimeError: _image_module::readpng: file not recognized as a PNG file
No idea, sorry.
Darren
Hi,
I just upgraded to matplotlib 0.98.1 on a ubuntu hardy heron system. I
have noticed two problems since the upgrade:
1) For any plot, if I try to look at the properties of a text object I
get an error related to FontProperties having no attribute 'items'. See
below:
In [1]: plot(range(10))
Out[1]: [<matplotlib.lines.Line2D object at 0x924f9ac>]
In [2]: xlh=get(gca(),'xticklabels')
In [3]: get(xlh[0])
------------------------------------------------------------
Traceback (most recent call last):
 File "<ipython console>", line 1, in <module>
 File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line
724, in get
 return getp(o, *args, **kwargs)
 File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line
716, in getp
 print '\n'.join(insp.pprint_getters())
 File "/usr/lib/python2.5/site-packages/matplotlib/artist.py", line
684, in pprint_getters
 s = str(val)
 File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
line 681, in __str__
 return self.get_fontconfig_pattern()
 File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
line 737, in get_fontconfig_pattern
 return generate_fontconfig_pattern(self)
 File
"/usr/lib/python2.5/site-packages/matplotlib/fontconfig_pattern.py",
line 164, in generate_fontconfig_pattern
 for key, val in d.items():
<type 'exceptions.AttributeError'>: 'FontProperties' object has no
attribute 'items'
2) I have noticed that the font used for the xticklabels and the font
used for the xlabel and contour labels appears to be different (example
attached). One appears to be serif and the other sans-serif. This
seems to be due to using tex for text rendering. I am not sure if this
also occurred before the update, but I didn't notice it previously.
Looking at the properties of the different text objects, it isn't
apparent that there should be a difference - both have font properties
that indicate sans-serif, but the text of tick labels appears to be
surrounded by $'s forcing it through the text parser, while that of the
contour labels is not. Is this difference normal or expected? Is there
a way around this? In particular, I would like to use sans-serif for
everything - is this possible while still using tex?
Thanks for the assistance.
Cheers,
David 
-- 
**********************************
David M. Kaplan
Charge de Recherche 1
Institut de Recherche pour le Developpement
Centre de Recherche Halieutique Mediterraneenne et Tropicale
av. Jean Monnet
B.P. 171
34203 Sete cedex
France
Phone: +33 (0)4 99 57 32 27
Fax: +33 (0)4 99 57 32 95
http://www.ur097.ird.fr/team/dkaplan/index.html
**********************************
From: S. N. <sor...@gm...> - 2008年07月10日 14:49:11
If I do some 2D line plots, I can activate the picker event on each line..
but if I change the scale of the axes using axes.set_xscale('log') /
axes.set_yscale('log') and then try to pick the lines, nothing happens. I
can't select them on the plot with the log scales, but if I click in the
area where they used to be on the linear scale the picker event is triggered
correctly...
I guess this is a bug?
Cheers,
Soren
Hi Darren,
I have tried rerunning our code with the change you suggested in the
make_dvi and make_png functions. I am still noticing failures however. I put
these at the bottom of this message. Strangely enough, these errors don't
seem to occur when there are a lot of files in my tex.cache directory. For
example, I ran the code (consisting of ~40 codes all making ~10-20 plots
each), successfully 3 times (the OSError wasn't raised at all, I used a
print statement to check). I realised after this that a lot of temp files
were in my tex.cache directory, so I emptied it and then I noticed that a
lot of failures occured when I ran the code the next time (the OSError I
showed previously was raised as well as the error messages shown below). It
seems weird that it should run fine when a lot of files are left in my temp
directory and not when it is empty?
Here are the error messages that are occuring now:
Traceback (most recent call last):
 File
"/home/spxiwh/ihope/852450000-852700000/nsbhinj_summary_plots/../executables/plotinspmissed",
line 625, in ?
 savePlot( opts, filename, titleText)
 File
"/home/spxiwh/ihope/852450000-852700000/nsbhinj_summary_plots/../executables/plotinspmissed",
line 108, in savePlot
 dpi_thumb=opts.figure_resolution)
 File
"/home/spxiwh/lscsoft/executables/cbc_s5_1yr_20070129/pylal//lib64/python2.4/site-packages/pylal/InspiralUtils.py",
line 54, in savefig_pylal
 fig.savefig(filename, dpi=dpi)
 File "/home/spxiwh/test/matplotlib/figure.py", line 682, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 456, in
print_figure
 self.draw()
 File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 392, in
draw
 self.figure.draw(renderer)
 File "/home/spxiwh/test/matplotlib/figure.py", line 544, in draw
 for a in self.axes: a.draw(renderer)
 File "/home/spxiwh/test/matplotlib/axes.py", line 1063, in draw
 a.draw(renderer)
 File "/home/spxiwh/test/matplotlib/axis.py", line 595, in draw
 self.label.draw(renderer)
 File "/home/spxiwh/test/matplotlib/text.py", line 340, in draw
 bbox, info = self._get_layout(renderer)
 File "/home/spxiwh/test/matplotlib/text.py", line 187, in _get_layout
 w,h = renderer.get_text_width_height(
 File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 240, in
get_text_width_height
 Z = texmanager.get_rgba(s, size, self.dpi.get(), rgb)
 File "/home/spxiwh/test/matplotlib/texmanager.py", line 334, in get_rgba
 pngfile = self.make_png(tex, fontsize, dpi, force=False)
 File "/home/spxiwh/test/matplotlib/texmanager.py", line 255, in make_png
 fh = file(outfile)
IOError: [Errno 2] No such file or directory:
'/home/spxiwh/.matplotlib/tex.cache/fb2014e54961855bd04020b61190867c.output'
Traceback (most recent call last):
 File
"/home/spxiwh/ihope/852450000-852700000/bnsinj_summary_plots/../executables/plotinspinj",
line 569, in ?
 'end_time', 'days', opts.time_axis, plot_type = 'linear' )
 File
"/home/spxiwh/ihope/852450000-852700000/bnsinj_summary_plots/../executables/plotinspinj",
line 94, in plot_parameter_accuracy
 dpi_thumb=opts.figure_resolution)
 File
"/home/spxiwh/lscsoft/executables/cbc_s5_1yr_20070129/pylal//lib64/python2.4/site-packages/pylal/InspiralUtils.py",
line 54, in savefig_pylal
 fig.savefig(filename, dpi=dpi)
 File "/home/spxiwh/test/matplotlib/figure.py", line 682, in savefig
 self.canvas.print_figure(*args, **kwargs)
 File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 456, in
print_figure
 self.draw()
 File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 392, in
draw
 self.figure.draw(renderer)
 File "/home/spxiwh/test/matplotlib/figure.py", line 544, in draw
 for a in self.axes: a.draw(renderer)
 File "/home/spxiwh/test/matplotlib/axes.py", line 1063, in draw
 a.draw(renderer)
 File "/home/spxiwh/test/matplotlib/axis.py", line 561, in draw
 tick.draw(renderer)
 File "/home/spxiwh/test/matplotlib/axis.py", line 161, in draw
 if self.label1On: self.label1.draw(renderer)
 File "/home/spxiwh/test/matplotlib/text.py", line 838, in draw
 Text.draw(self, renderer)
 File "/home/spxiwh/test/matplotlib/text.py", line 340, in draw
 bbox, info = self._get_layout(renderer)
 File "/home/spxiwh/test/matplotlib/text.py", line 187, in _get_layout
 w,h = renderer.get_text_width_height(
 File "/home/spxiwh/test/matplotlib/backends/backend_agg.py", line 240, in
get_text_width_height
 Z = texmanager.get_rgba(s, size, self.dpi.get(), rgb)
 File "/home/spxiwh/test/matplotlib/texmanager.py", line 334, in get_rgba
 pngfile = self.make_png(tex, fontsize, dpi, force=False)
 File "/home/spxiwh/test/matplotlib/texmanager.py", line 247, in make_png
 dvifile = self.make_dvi(tex, fontsize)
 File "/home/spxiwh/test/matplotlib/texmanager.py", line 223, in make_dvi
 fh = file(outfile)
IOError: [Errno 2] No such file or directory:
'/home/spxiwh/.matplotlib/tex.cache/7e534aafdc12681d1ef0d36df4963de8.output'
And once I noticed:
Traceback (most recent call last):
 File
"/home/spxiwh/ihope/852450000-852700000/allinj_summary_plots/../executables/plotinspmissed",
line 661, in ?
 dpi_thumb=opts.figure_resolution)
 File
"/home/spxiwh/lscsoft/executables/cbc_s5_1yr_20070129/pylal//lib64/python2.4/site-packages/pylal/InspiralUtils.py",
line 54, in savefig_pylal
 fig.savefig(filename, dpi=dpi)
 File "/usr/lib64/python2.4/site-packages/matplotlib/figure.py", line 682,
in savefig
 self.canvas.print_figure(*args, **kwargs)
 File
"/usr/lib64/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 456, in print_figure
 self.draw()
 File
"/usr/lib64/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 392, in draw
 self.figure.draw(renderer)
 File "/usr/lib64/python2.4/site-packages/matplotlib/figure.py", line 544,
in draw
 for a in self.axes: a.draw(renderer)
 File "/usr/lib64/python2.4/site-packages/matplotlib/axes.py", line 1063,
in draw
 a.draw(renderer)
 File "/usr/lib64/python2.4/site-packages/matplotlib/text.py", line 340, in
draw
 bbox, info = self._get_layout(renderer)
 File "/usr/lib64/python2.4/site-packages/matplotlib/text.py", line 187, in
_get_layout
 w,h = renderer.get_text_width_height(
 File
"/usr/lib64/python2.4/site-packages/matplotlib/backends/backend_agg.py",
line 240, in get_text_width_height
 Z = texmanager.get_rgba(s, size, self.dpi.get(), rgb)
 File "/usr/lib64/python2.4/site-packages/matplotlib/texmanager.py", line
330, in get_rgba
 X = readpng(os.path.join(self.texcache, pngfile))
RuntimeError: _image_module::readpng: file not recognized as a PNG file
Cheers
Ian
2008年7月10日 Darren Dale <dsd...@gm...>:
> Hi Ian,
>
> On Thursday 10 July 2008 06:03:54 am Ian Harry wrote:
> > Hi all,
> >
> > Myself and my colleagues use, and have used, matplotlib and it's Tex
> > capabilities quite extensively to create plots to assist in the
> > gravitational wave searches we perform. (and it has been a great tool for
> > us
> >
> > :-) ). However recently we have been running into problems when we have
> >
> > started automating our plot generation by running multiple plotting jobs
> > concurrently using the condor scheduler (and dagmans). Many of our
> plotting
> > jobs fail with messages such as the one below:
> >
> > ---snip---
> >
> > Traceback (most recent call last):
> > File
> > "/home/romain/Projects/
> >
> ligovirgo/s5_2yr_lv_lowcbc_20080625/868815014-868901414/868815014-868901414
> >/inj001_summary_plots/../executables/plotinjnum", line 298, in ?
> > 'eff_dist_h')
> > File
> >
> "/home/romain/Projects/ligovirgo/s5_2yr_lv_lowcbc_20080625/868815014-868901
> >414/868815014-868901414/inj001_summary_plots/../executables/plotinjnum",
> > line 119, in plot_found_missed
> > fname_thumb = InspiralUtils.savefig_pylal(filename=fname,
> > doThumb=True, dpi_thumb=opts.figure_resolution)
> > File
> >
> "/home/romain/codes/s5_2yr_lv_lowcbc_20080625/pylal/lib64/python2.4/site-pa
> >ckages/pylal/InspiralUtils.py", line 58, in savefig_pylal
> > fig.savefig(filename_thumb, dpi=dpi_thumb)
> > ....
> > File "/usr/lib64/python2.4/site-packages/matplotlib/texmanager.py", line
> > 259, in make_png
> > os.remove(outfile)
> > OSError: [Errno 2] No such file or directory:
> >
> '/home/romain/.matplotlib/tex.cache/ae479c90ff242327b54af004a0846188.output
> >'
> >
> > ---snip---
> >
> > My feeling is that when the code invokes the Tex 'bit' it creates a temp
> > file in ~/matplotlib/tex.cache and then deletes it and all other temp tex
> > files when it finishes the Tex 'bit'. This would cause problems if
> another
> > job is in the middle of running Tex when the other job deletes it's temp
> > files!
> >
> > We are running a slightly old version of matplotlib (0.87.7), as we run
> on
> > multiple clusters our sys admins tend to only update software when there
> is
> > a need to and we have had no other problems with matplotlib, I apologize
> if
> > this has been fixed in the meantime (I did do a quick search of the
> mailing
> > list archive but found nothing). All our clusters currently run Fedora
> Core
> > 4 (we're going to move to CentOS 5).
> >
> > Currently we are getting around this by forcing condor to retry the
> failed
> > jobs 2/3 times, this catches most of these errors. Another solution would
> > be to limit the number of jobs running to 1 BUT as we run dagmen from
> > within one 'super' dagman it would prove difficult to limit jobs from
> > multiple dagmen.
> >
> > Anyway if anyone has any ideas of how to solve this I would appreciate
> > this. Also if there are any options where we can set the location of
> these
> > temp tex files and use a different directory for each job (or stop
> > matplotlib deleting other temp files) that would help us.
>
> I'm really hesitant to mess around with the location of the temp files. It
> was
> a bit painfull trying to get usetex to work across platforms.
>
> Instead, would you try replacing:
>
> os.remove(outfile)
>
> with:
>
> try: os.remove(outfile)
> except OSError: pass
>
> Let me know if that fixes it, and if you need to wrap any other file
> deletions.
>
> Thanks,
> Darren
>
-- 
---------------------------------------------------------------------------
Ian Harry
School of Physics & Astronomy
Queens Buildings, The Parade
Cardiff, CF24 3AA
Email: Ian...@as...
Phone: (+44) 29 208 75120
Mobile: (+44) 7890 479090
---------------------------------------------------------------------------
From: Michael D. <md...@st...> - 2008年07月10日 13:59:45
Changing the scale shouldn't remove the lines -- but it's possible there 
is a bug that moves them out of the visible area. Can you provide some 
standalone code that reproduces this problem?
Cheers,
Mike
Søren Nielsen wrote:
> Hi,
>
> When I change the xscale and yscale my plots go missing... i use 
> axes.set_xscale('linear'), axes.set_yscale('liner) or 
> axes.set_xscale('log'), axes.set_yscale('log') ... I have a button 
> that changes between those two.. but a change removes the 2D lines i 
> have on them... do I need to change something in the line objects too?
>
> Regards,
> Soren
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: S. N. <sor...@gm...> - 2008年07月10日 13:55:12
Hi,
When I change the xscale and yscale my plots go missing... i use
axes.set_xscale('linear'), axes.set_yscale('liner) or
axes.set_xscale('log'), axes.set_yscale('log') ... I have a button that
changes between those two.. but a change removes the 2D lines i have on
them... do I need to change something in the line objects too?
Regards,
Soren
From: dragan s. <sav...@ya...> - 2008年07月10日 13:04:24
Hi everybody!
I am new to matplotlib and I have a question. I am running matplotlib from a main program in python as a separate thread. When I first launch matplotlib it works fine. On my second try when the main program is still running I try to execute it again but the plotting window is shown only for a sec and then it disappears. The last command is show(). This show() command should block the thread from dying and should unblock, leave the thread to die, when I close the matplotlib plotting window. Somehow this doesn't happen. Any clues on how I can fix this? Maybe I should be using something else then show() method?
Manny thanks!
Cheers, Dragan.
 
Hi Ian,
On Thursday 10 July 2008 06:03:54 am Ian Harry wrote:
> Hi all,
>
> Myself and my colleagues use, and have used, matplotlib and it's Tex
> capabilities quite extensively to create plots to assist in the
> gravitational wave searches we perform. (and it has been a great tool for
> us
>
> :-) ). However recently we have been running into problems when we have
>
> started automating our plot generation by running multiple plotting jobs
> concurrently using the condor scheduler (and dagmans). Many of our plotting
> jobs fail with messages such as the one below:
>
> ---snip---
>
> Traceback (most recent call last):
> File
> "/home/romain/Projects/
> ligovirgo/s5_2yr_lv_lowcbc_20080625/868815014-868901414/868815014-868901414
>/inj001_summary_plots/../executables/plotinjnum", line 298, in ?
> 'eff_dist_h')
> File
> "/home/romain/Projects/ligovirgo/s5_2yr_lv_lowcbc_20080625/868815014-868901
>414/868815014-868901414/inj001_summary_plots/../executables/plotinjnum",
> line 119, in plot_found_missed
> fname_thumb = InspiralUtils.savefig_pylal(filename=fname,
> doThumb=True, dpi_thumb=opts.figure_resolution)
> File
> "/home/romain/codes/s5_2yr_lv_lowcbc_20080625/pylal/lib64/python2.4/site-pa
>ckages/pylal/InspiralUtils.py", line 58, in savefig_pylal
> fig.savefig(filename_thumb, dpi=dpi_thumb)
> ....
> File "/usr/lib64/python2.4/site-packages/matplotlib/texmanager.py", line
> 259, in make_png
> os.remove(outfile)
> OSError: [Errno 2] No such file or directory:
> '/home/romain/.matplotlib/tex.cache/ae479c90ff242327b54af004a0846188.output
>'
>
> ---snip---
>
> My feeling is that when the code invokes the Tex 'bit' it creates a temp
> file in ~/matplotlib/tex.cache and then deletes it and all other temp tex
> files when it finishes the Tex 'bit'. This would cause problems if another
> job is in the middle of running Tex when the other job deletes it's temp
> files!
>
> We are running a slightly old version of matplotlib (0.87.7), as we run on
> multiple clusters our sys admins tend to only update software when there is
> a need to and we have had no other problems with matplotlib, I apologize if
> this has been fixed in the meantime (I did do a quick search of the mailing
> list archive but found nothing). All our clusters currently run Fedora Core
> 4 (we're going to move to CentOS 5).
>
> Currently we are getting around this by forcing condor to retry the failed
> jobs 2/3 times, this catches most of these errors. Another solution would
> be to limit the number of jobs running to 1 BUT as we run dagmen from
> within one 'super' dagman it would prove difficult to limit jobs from
> multiple dagmen.
>
> Anyway if anyone has any ideas of how to solve this I would appreciate
> this. Also if there are any options where we can set the location of these
> temp tex files and use a different directory for each job (or stop
> matplotlib deleting other temp files) that would help us.
I'm really hesitant to mess around with the location of the temp files. It was 
a bit painfull trying to get usetex to work across platforms.
Instead, would you try replacing:
os.remove(outfile)
with:
try: os.remove(outfile)
except OSError: pass
Let me know if that fixes it, and if you need to wrap any other file 
deletions.
Thanks,
Darren
From: Antonio G. <ja...@ca...> - 2008年07月10日 12:16:57
Søren Nielsen wrote:
> Is there a way I can hide a line plot? I have several line plots, and I 
> want to make a function to enable or disable a plot.. How do I tell each 
> line apart and remove/reinsert them?
Try this in an interactive session, and see if it helps:
ax = figure().add_subplot(111)
a = ax.plot(rand(10), 'k')[0]
b = ax.plot(rand(10), 'r')[0]
ax.figure.canvas.draw()
a.set_visible(False)
ax.figure.canvas.draw()
Regards,
Antonio
From: Michael D. <md...@st...> - 2008年07月10日 12:16:12
When you create the plot, it returns a list of line objects. You can 
use this object to remove itself from the axes, and add it back it 
later. Hope this helps::
In [1]: l1 = plot([1,2,3])
In [2]: l2 = plot([4,5,6])
In [4]: l1
Out[4]: [<matplotlib.lines.Line2D object at 0xb676124c>]
# Remove the first plot
In [6]: l1[0].remove()
# Put it back
In [9]: axes().add_line(l1[0])
Cheers,
Mike
Søren Nielsen wrote:
> Hi,
>
> Is there a way I can hide a line plot? I have several line plots, and 
> I want to make a function to enable or disable a plot.. How do I tell 
> each line apart and remove/reinsert them?
>
> Anyone tried this? I was seeking for a line ID of somekind in 
> matplotlib.lines... but didn't see any.
>
> Thanks,
> Soren
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> ------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: S. N. <sor...@gm...> - 2008年07月10日 12:08:52
Hi,
Is there a way I can hide a line plot? I have several line plots, and I want
to make a function to enable or disable a plot.. How do I tell each line
apart and remove/reinsert them?
Anyone tried this? I was seeking for a line ID of somekind in
matplotlib.lines... but didn't see any.
Thanks,
Soren
From: Manuel M. <mm...@as...> - 2008年07月10日 11:58:25
Angela Rivera Campos wrote:
> Hi,
> 
> I'm quite a newbie on matplotlib.
> 
> I'm trying to get some data from a file. I've got a function that reads 
> the data from the file and stores it in a tuple as a set of floats. When 
> I use this without importing pylab it just go well but when I do it 
> after importing this module there's a rounding and I don't get the 
> proper data:
> 
> ----------------------------
> >>> import myModule as m
> >>> spc = m.Collection()
> >>> spc.ReadCollection('file')
> >>> sp = spc.GetCSVBlock('00074')
> >>> sp.GetDataRecord(0)
> (0.0, 0.10000000000000001, 0.050345000000000001, 616.0, 
> 24.818999999999999, 616.0)
> 
> ---
> 
> >>> import myModule as m
> >>> from pylab import *
> >>> spc = m.Collection()
> >>> spc.ReadCollection('file')
> >>> sp = spc.GetCSVBlock('00074')
> >>> sp.GetDataRecord(0)
> (0.0, 0.0, 0.0, 616.0, 24.0, 616.0)
> ----------------------------
> 
> What's the problem here? What can I do to avoid it?
Try
 import pylab
instead of
 from pylab import *
Manuel
> Thanks in advance,
> 
> AR
> 
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Angela R. C. <riv...@in...> - 2008年07月10日 11:43:51
Hi,
I'm quite a newbie on matplotlib.
I'm trying to get some data from a file. I've got a function that reads 
the data from the file and stores it in a tuple as a set of floats. When 
I use this without importing pylab it just go well but when I do it 
after importing this module there's a rounding and I don't get the 
proper data:
----------------------------
 >>> import myModule as m
 >>> spc = m.Collection()
 >>> spc.ReadCollection('file')
 >>> sp = spc.GetCSVBlock('00074')
 >>> sp.GetDataRecord(0)
(0.0, 0.10000000000000001, 0.050345000000000001, 616.0, 
24.818999999999999, 616.0)
---
 >>> import myModule as m
 >>> from pylab import *
 >>> spc = m.Collection()
 >>> spc.ReadCollection('file')
 >>> sp = spc.GetCSVBlock('00074')
 >>> sp.GetDataRecord(0)
(0.0, 0.0, 0.0, 616.0, 24.0, 616.0)
----------------------------
What's the problem here? What can I do to avoid it?
Thanks in advance,
AR
From: Bryan C. <br...@co...> - 2008年07月10日 10:18:51
On Wed, 2008年07月09日 at 18:40 +0200, anirudh vij wrote:
> > We have been warning that 3D plotting was unsupported and needed someone to
> > volunteer to maintain it for quite a while now. Nobody answered the call, and
> > 3d capabilities did not survive the transition to the new transforms in
> > mpl-0.98, so it was removed, However...
> >
> 
> hmm. Mayavi2 has a mlab module thats under active development. It aims
> to do the same stuff that matlab 3D plots do. However, svn currently
> crashes for me.
An alterative to mpl/mayavi for 3d is Pyx (see
http://pyx.sourceforge.net/examples/3dgraphs/color.html ), although it's
not interactive.
BC
Hi all,
Myself and my colleagues use, and have used, matplotlib and it's Tex
capabilities quite extensively to create plots to assist in the
gravitational wave searches we perform. (and it has been a great tool for us
:-) ). However recently we have been running into problems when we have
started automating our plot generation by running multiple plotting jobs
concurrently using the condor scheduler (and dagmans). Many of our plotting
jobs fail with messages such as the one below:
---snip---
Traceback (most recent call last):
 File
"/home/romain/Projects/
ligovirgo/s5_2yr_lv_lowcbc_20080625/868815014-868901414/868815014-868901414/inj001_summary_plots/../executables/plotinjnum",
line 298, in ?
 'eff_dist_h')
 File
"/home/romain/Projects/ligovirgo/s5_2yr_lv_lowcbc_20080625/868815014-868901414/868815014-868901414/inj001_summary_plots/../executables/plotinjnum",
line 119, in plot_found_missed
 fname_thumb = InspiralUtils.savefig_pylal(filename=fname,
doThumb=True, dpi_thumb=opts.figure_resolution)
 File
"/home/romain/codes/s5_2yr_lv_lowcbc_20080625/pylal/lib64/python2.4/site-packages/pylal/InspiralUtils.py",
line 58, in savefig_pylal
 fig.savefig(filename_thumb, dpi=dpi_thumb)
....
 File "/usr/lib64/python2.4/site-packages/matplotlib/texmanager.py", line
259, in make_png
 os.remove(outfile)
 OSError: [Errno 2] No such file or directory:
'/home/romain/.matplotlib/tex.cache/ae479c90ff242327b54af004a0846188.output'
---snip---
My feeling is that when the code invokes the Tex 'bit' it creates a temp
file in ~/matplotlib/tex.cache and then deletes it and all other temp tex
files when it finishes the Tex 'bit'. This would cause problems if another
job is in the middle of running Tex when the other job deletes it's temp
files!
We are running a slightly old version of matplotlib (0.87.7), as we run on
multiple clusters our sys admins tend to only update software when there is
a need to and we have had no other problems with matplotlib, I apologize if
this has been fixed in the meantime (I did do a quick search of the mailing
list archive but found nothing). All our clusters currently run Fedora Core
4 (we're going to move to CentOS 5).
Currently we are getting around this by forcing condor to retry the failed
jobs 2/3 times, this catches most of these errors. Another solution would be
to limit the number of jobs running to 1 BUT as we run dagmen from within
one 'super' dagman it would prove difficult to limit jobs from multiple
dagmen.
Anyway if anyone has any ideas of how to solve this I would appreciate this.
Also if there are any options where we can set the location of these temp
tex files and use a different directory for each job (or stop matplotlib
deleting other temp files) that would help us.
Thanks in advance for any help
Ian Harry
-- 
---------------------------------------------------------------------------
Ian Harry
School of Physics & Astronomy
Queens Buildings, The Parade
Cardiff, CF24 3AA
Email: Ian...@as...
Phone: (+44) 29 208 75120
Mobile: (+44) 7890 479090
---------------------------------------------------------------------------
From: Sandro T. <mat...@gm...> - 2008年07月10日 06:54:23
Hello Ben,
On Wed, Jul 9, 2008 at 19:37, Ben Axelrod <bax...@co...> wrote:
> I get errors when I add:
>
> deb http://anakonda.altervista.org/debian packages/
>
> deb-src http://anakonda.altervista.org/debian sources/
>
> to my /etc/apt/sources.list. Is this still the preferred method for
> installing on Debian?
Matplotlib is available on official debian repository[1] at version
0.98.1 (and hopefully soon 0.98.2) both for unstable and testing.
Maybe you're on stable?
Cheers,
Sandro
[1] http://packages.qa.debian.org/m/matplotlib.html
-- 
Sandro Tosi (aka morph, Morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
From: Marjolaine R. <mro...@cs...> - 2008年07月10日 06:34:53
Thanks Eric,
That is much better. I am going to try and implement it now and see how I go. I will let you know.
Regards, Marjolaine.
>>> Eric Firing <ef...@ha...> 07/09/08 11:12 PM >>>
Marjolaine Rouault wrote:
> Hi,
> 
> I don't understand how one creates his own colormap. i am using
> matplotlib and I have checked the example in
> http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps but I can't
> really understand how it works. Are there any other examples out
> there? I want to create a colormap a bit like the one at this url:
> 
> http://www.pyngl.ucar.edu/Graphics/Images/ViBlGrWhYeOrRe.gif
> 
> best regards, Marjolaine.
> 
> 
> 
Marjolaine,
Depending on your starting point--what you know about your desired 
colormap--you can use either a LinearSegmentedColormap or a 
ListedColormap. If you already have a colormap in the form of a list of 
evenly-spaced colors, then the simplest way to get it into mpl is by 
using that list to initialize a ListedColormap. If, instead, you have a 
general idea of how you want R, G, and B to vary over the range of the 
map, then you probably need the LinearSegmentedColormap.
Every description of the LinearSegmentedColormap class that I have seen 
is confusing, even though the way it works is fairly simple. Let's see 
if I can make it a little less confusing.
Example: suppose you want red to increase from 0 to 1 over the bottom 
half, green to do the same over the middle half, and blue over the top 
half. Then you would use:
cdict = { 'red': ((0, 0, 0),
 (0.5, 1, 1),
 (1, 1, 1)),
 'green': ((0, 0, 0),
 (0.25, 0, 0),
 (0.75, 1, 1),
 (1, 1, 1)),
 'blue': ((0, 0, 0),
 (0.5, 0, 0),
 (1, 1, 1))}
If, as in this example, there are no discontinuities in the r, g, and b 
components, then it is quite simple: the second and third element of 
each tuple, above, is the same--call it "y". The first element ("x") 
defines interpolation intervals over the full range of 0 to 1, and it 
must span that whole range. In other words, the values of x divide the 
0-to-1 range into a set of segments, and y gives the end-point color 
values for each segment.
Now consider the green. cdict['green'] is saying that for
0 <= x <= 0.25, y is zero; no green.
0.25 < x <= 0.75, y varies linearly from 0 to 1.
x > 0.75, y remains at 1, full green.
If there are discontinuities, then it is a little more complicated. 
Label the 3 elements in each row in the cdict entry for a given color as 
(x, y0, y1). Then for values of x between x[i] and x[i+1] the color 
value is interpolated between y1[i] and y0[i+1].
Going back to the cookbook example, look at cdict['red']; because y0 != 
y1, it is saying that for x from 0 to 0.5, red increases from 0 to 1, 
but then it jumps down, so that for x from 0.5 to 1, red increases from 
0.7 to 1. Green ramps from 0 to 1 as x goes from 0 to 0.5, then jumps 
back to 0, and ramps back to 1 as x goes from 0.5 to 1.
row i: x y0 y1
 /
 /
row i+1: x y0 y1
Above is an attempt to show that for x in the range x[i] to x[i+1], the 
interpolation is between y1[i] and y0[i+1]. So, y0[0] and y1[-1] are 
never used.
I hope I got all that right--I would welcome close checking. I want to 
get an adequate and correct explanation into the standard mpl documentation.
Eric
-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
From: Ryan M. <rm...@gm...> - 2008年07月10日 04:20:02
Lubos Vrbka wrote:
> hello,
> 
>> why is it actually not possible to do something like the following piece 
>> of code?
>> ioff()
>> plot commands
>> draw()
>> ion()
> actually, i did some test now (modification of the example 
> http://www.scipy.org/Cookbook/Matplotlib/Animations site):
> 
> from pylab import *
> ioff()
> x = arange(0,2*pi,0.01) # x-array
> line, = plot(x,sin(x))
> draw()
> 
> displays nothing, then
> 
> ion()
> for i in arange(1,200):
> line.set_ydata(sin(x+i/10.0)) # update the data
> draw() # redraw the canvas
> 
> displays nothing as well, but shows the same 'lag' as when running the 
> whole code in interactive mode. that means that the data is processed, 
> the graphics is plotted, just the window is not displayed.
> 
> i thought that ioff() is present exactly for this purpose. 
> unfortunately, the documentation page
> 
> http://matplotlib.sourceforge.net/interactive.html
> 
> shows only an example where an image file is produced first with ioff(), 
> the figure is closed and something is then displayed with ion().
> 
> when i later issue another plot() command (i.e., plot(random(20), 
> random(20)), it is displayed and shows also the last part of the sin(x) 
> plot...
> 
> the thing i want to achieve is maybe impossible - i'd just love to know 
> why, or what am i doing wrong... i'm very grateful for any hints.
Try looking at the dynamic_image_*.py in the examples directory (or 
examples/animation for version 0.98.x). I've personally used the 
dynamic_image_gtkagg.py approach for (what I think is) a similar use 
case to yours. Before finding that one, I went through a variety of 
approaches with threading, ion()/ioff() and draw().
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Ryan M. <rm...@gm...> - 2008年07月10日 04:09:53
James K. Gruetzner wrote:
> Thanks for the suggestion, Michael. Reading it led to a bit of a forehead
> slap.
> 
> Unfortunately, that didn't work either. Curiously, it appears that
> the "show()" command does not return.
> 
> ----- CODE SECTION -------------
> #!/usr/local/bin/python
> 
> import os,sys
> import pylab
> 
> def main():
> x = pylab.linspace(-10,10,100)
> y = pylab.sin(x)
> pylab.plot(x,y)
> sys.stderr.write("Begun.")
> pylab.show()
> sys.stderr.write("Done.")
> 
> if __name__ == "__main__":
> main()
> ---- END CODE -------------
> 
> When executed from the command line:
> $ ./test.py &
> . . . the plot displays; clicking on the X closes it, but the process keeps
> on running.
> 
> When executed as an argument to python:
> $ python test.py &
> . . . the same behavior (except it's a python process which hangs).
> 
> The two sys.stderr.write() statements are for debugging. The first one
> executes; the second does not. My conclusion is that the show() command does
> not return.
> 
> ----------
> When I operate interactively,
> the command "pylab.plot(x,y)" opens a widow labeled "Figure 1".
> . . . then . . .
> the command "show()" writes the plot to that window (i.e., sine plot).
> 
> Clicking the X in the figure window causes the window to disappear, but
> the "show()" command fails to return.
> 
> --------------
> 
> So . . . I figure that the lack of show() returning is the root problem.
> 
> Any suggestions?
> 
> I'm running Fedora 8, python 2.5.1, and matplotlib 0.91.2-1.fc8 from the yum
> repository. Backend is set to GTKAgg in my matplotlibrc file.
> 
(On this list top-posting is frowned upon -- it makes the conversation 
difficult to follow.)
Your analysis is correct, the call to show() activates the GUI mainloop 
and does not return until the window is closed. Within ipython there is 
some magic that occurs that runs the mainloop in a separate thread. 
What do you need to do after the call to show()?
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Showing 24 results of 24

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 によって変換されたページ (->オリジナル) /