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 results of 395

<< < 1 .. 5 6 7 8 9 .. 16 > >> (Page 7 of 16)
From: Michael D. <md...@st...> - 2008年07月17日 17:42:46
Anyone have any thoughts on this? It seems like it's serious enough to 
try to resolve before the next bugfix release.
Cheers,
Mike
Michael Droettboom wrote:
> Yes, it should be. I'm further puzzled that removing "del 
> Gcf.figs[num]" prevents the memory leak. There is some side effect that 
> happens when all of the figures have been closed (I think it shuts down 
> the GUI mainloop), that keeping at least one figure around at all times 
> avoids. But I haven't been able to get to the bottom of that, just a 
> half-supported theory at this point.
>
> Cheers,
> Mike
>
> laurent oget wrote:
> 
>> I am puzzled. Wasn't the whole point of close() to avoid memory leaks?
>>
>> Laurent
>>
>> 2008年7月15日 Michael Droettboom <md...@st... <mailto:md...@st...>>:
>>
>> Yes, as of r5747 twinx (well, shared axes specifically) no longer
>> leaks.
>>
>> Manuel has discovered a seemingly generic leak that occurs when
>> pyplot.close() is called and running a GUI backend. I can confirm his
>> results with the script he last sent.
>>
>> Cheers,
>> Mike
>>
>> Manuel Metz wrote:
>> > John Hunter wrote:
>> >> On Mon, Jul 14, 2008 at 3:05 PM, Michael Droettboom
>> <md...@st... <mailto:md...@st...>>
>> >> wrote:
>> >>> I can confirm this.
>> >>>
>> >>> Commenting out "del Gcf.figs[num]" in Gcf.destroy (in
>> >>> _pylab_helpers.py)
>> >>> also seems to resolve the leak. But I have no idea why, so I
>> won't
>> >>> commit it just yet. I don't have much time to look deeper
>> now. Does
>> >>> anyone (who probably understands figure management better than
>> me) have
>> >>> an idea what might cause this?
>> >>
>> >> Can you post the script you are using to test -- I am a little
>> >> confused from reading this thread by whether or not twinx is
>> >> implicated. Also, I saw that you committed some changes
>> vis-a-vis the
>> >> twinx leak
>> >>
>> >> r5747 | mdboom | 2008年07月11日 13:21:53 -0500 (2008年7月11日) | 2
>> >> lines
>> >>
>> >> Fix memory leak when using shared axes.
>> >>
>> >> so I thought that part was resolved already...
>> >>
>> >> JDH
>> >
>> > I use a modified version of the script Laurent Oget posted (see
>> > attachment). Here is the output if I don't comment out PL.close(1).
>> >
>> > ~/python/test$ python looptest.py -dGTK
>> > 0 GC 69354 69354 0 13854
>> > 100 GC 84354 150 0 15163
>> > 200 GC 99354 150 0 16306
>> > 300 GC 114354 150 0 17364
>> > 400 GC 129354 150 0 18576
>> > ~/python/test$ python looptest.py -dTK
>> > 0 GC 69521 69521 0 14065
>> > 100 GC 84521 150 0 15444
>> > 200 GC 99521 150 0 16581
>> > 300 GC 114521 150 0 17719
>> > 400 GC 129521 150 0 18715
>> > ~/python/test$ python looptest.py -dPS
>> > 0 GC 59307 59307 0 7705
>> > 100 GC 59307 0 0 8037
>> > 200 GC 59307 0 0 8038
>> > 300 GC 59307 0 0 8038
>> > 400 GC 59307 0 0 8038
>> >
>> > (so for the window-less backend PS no objects are left)
>> >
>> > And now I commented out the line PL.close(1):
>> >
>> > ~/python/test$ python looptest.py -dGTK
>> > 0 GC 69379 69379 0 13855
>> > 100 GC 69379 0 0 14253
>> > 200 GC 69379 0 0 14253
>> > 300 GC 69379 0 0 14253
>> > 400 GC 69379 0 0 14252
>> >
>> > Manuel
>>
>> --
>> Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win
>> great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in
>> the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> <mailto: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: John H. <jd...@gm...> - 2008年07月17日 14:56:35
On Wed, Jul 16, 2008 at 6:59 PM, Alan G Isaac <ai...@am...> wrote:
> I assume you know of Robert Kern's code?
> <URL:http://cours-info.iut-bm.univ-fcomte.fr/docs/python/scipy/scipy.sandbox.delaunay-module.html>
I was aware of the project but always assumed he was relying on some
GPL/LGPL code since it wasn't in scipy proper, but I now see this is
not the case. I just talked with Jeff Whitaker who wrote the griddata
functionality on top of NCAR's natgrid (GPL), and he expressed a
willingness to port his code to use Robert's code, which we could
include in mpl. Robert, what is the reason this hasn't gone into
scipy proper, and do you see any problems with us folding it into mpl
for use by griddata?
Thanks,
JDH
On Wednesday 16 July 2008 07:20:59 am Ian Harry wrote:
> [spxiwh@sugar 07:14 AM matplotlib]$ diff texmanager.py
> /usr/lib64/python2.4/site-packages/matplotlib/texmanager.py
> 248c248
> < fh = file(outfile,'a')
> ---
>
> > fh = file(outfile)
>
> 252,254c252
> < else:
> < try: verbose.report(fh.read(), 'debug')
> < except: pass
> ---
>
> > else: verbose.report(fh.read(), 'debug')
>
> 259,261c257,258
> < else:
> < try: os.remove(fname)
> < except: pass
> ---
>
> > else: os.remove(fname)
>
> 280c277
> < fh = file(outfile,'a')
> ---
>
> > fh = file(outfile)
>
> 285,287c282
> < else:
> < try: verbose.report(fh.read(), 'debug')
> < except: pass
> ---
>
> > else: verbose.report(fh.read(), 'debug')
>
> 289,290c284
> < try: os.remove(outfile)
> < except: pass
> ---
>
> > os.remove(outfile)
>
> 314c308
> < # else: verbose.report(fh.read(), 'debug')
> ---
>
> > else: verbose.report(fh.read(), 'debug')
>
> --snip--
I took a different approach:
Index: lib/matplotlib/texmanager.py
===================================================================
--- lib/matplotlib/texmanager.py (revision 5771)
+++ lib/matplotlib/texmanager.py (working copy)
@@ -273,16 +273,22 @@
 %(os.path.split(texfile)[-1], outfile))
 mpl.verbose.report(command, 'debug')
 exit_status = os.system(command)
- fh = file(outfile)
+ try:
+ fh = file(outfile)
+ report = fh.read()
+ fh.close()
+ except IOError:
+ report = 'No latex error report available.'
 if exit_status:
 raise RuntimeError(('LaTeX was not able to process the 
following \
-string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + 
fh.read())
- else: mpl.verbose.report(fh.read(), 'debug')
- fh.close()
+string:\n%s\nHere is the full report generated by LaTeX: \n\n'% repr(tex)) + 
report)
+ else: mpl.verbose.report(report, 'debug')
 for fname in glob.glob(basefile+'*'):
 if fname.endswith('dvi'): pass
 elif fname.endswith('tex'): pass
- else: os.remove(fname)
+ else:
+ try: os.remove(fname)
+ except OSError: pass
 return dvifile
@@ -305,14 +311,19 @@
 os.path.split(dvifile)[-1], outfile))
 mpl.verbose.report(command, 'debug')
 exit_status = os.system(command)
- fh = file(outfile)
+ try:
+ fh = file(outfile)
+ report = fh.read()
+ fh.close()
+ except IOError:
+ report = 'No dvipng error report available.'
 if exit_status:
 raise RuntimeError('dvipng was not able to \
 process the flowing file:\n%s\nHere is the full report generated by dvipng: \
-\n\n'% dvifile + fh.read())
- else: mpl.verbose.report(fh.read(), 'debug')
- fh.close()
- os.remove(outfile)
+\n\n'% dvifile + report)
+ else: mpl.verbose.report(report, 'debug')
+ try: os.remove(outfile)
+ except OSError: pass
 return pngfile
Would you update from svn and see if it works for you?
Thanks,
Darren
From: John H. <jd...@gm...> - 2008年07月17日 11:39:47
On Thu, Jul 17, 2008 at 1:22 AM, Angela Rivera Campos <riv...@in...> wrote:
> Well, I can assure you that I am neither working as root, I might be a
> newbie to matplotlib but not to linux, nor have any problem with the
> display. This problem is happening in both machines, remote (ssh -X, for
> sure, I've tested several times) and local, so no ssh conection. Anyway,
> I'm going to test a few more things and will let you know what happens.
Very strange indeed -- the error clear indicates you cannot connect to
the display. You should see the same in the same nvironment if you
simply
>>> import gtk
as the first line. Do you?
JDH
From: Tim M. <tim...@gm...> - 2008年07月17日 07:34:36
 > I'd love to see it included to -- I believe the problem is finding a
 > good code that is BSD compatible.
Yes.
Some examples on plotting data using spatial interpolation would be very 
nice.
One with the delauny package:
see below at: http://scipy.org/scipy/scikits/
And one with griddata:
http://code.google.com/p/griddata-python/
We could use the accepted data sets from
http://www.itc.nl/personal/rossiter/teach/lecnotes.html#l6
I have tested the griddata package but didn't reach very far due to 
other task to be accomplished earlier.
Kind regards,
Timmie
From: Eric F. <ef...@ha...> - 2008年07月17日 06:52:06
Chee Sing Lee wrote:
> Hello,
> 
> I'm pretty new to matplotlib, so please bear with me.
> 
> I am writing an application that includes a hexagonally binned scatter
> plot that updates periodically, up to a couple times a second. My
> current approach is clearing axes.collections, calling hexbin() with
> the updated data, and then calling canvas.draw(). It works, but it is
> entirely too slow. I would like to implement the blitting animation
> technique shown in the matplotlib cookbook, but the collection object
> returned by hexbin() doesn't seem to have any sort of set_data method
> to update the data. Any suggestions?
My guess is that the entire hexbin method is fundamentally slow. Among 
other things, it is looping through all input values in python. In 
addition, the rendering, using a poly collection, is similar to pcolor, 
and that is also slow when the number of polygons is large. Profiling a 
run of hexbin might show whether there are obvious opportunities to 
speed it up.
Eric
> 
> I am using the wxPython GUI tookit, and FigureCanvasWxAgg.
> 
> Thanks,
> Chee Sing Lee
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Angela R. C. <riv...@in...> - 2008年07月17日 06:22:39
>> If you cannot open the display, most likely it is because either you
>> are running as root (bad, bad) or you are running over a remot
>> connection (ssh) and do not have X11 forwarding properly enabled or
>> configures. If you want to use mpl with an interactive window, you
>> will need to have access to the display. The fact that you see this
>> error only on the first time you import pylab is typical of exceptions
>> that are thrown at module import time -- python only tries to import
>> once so you see the exception only once. To solve this, trying
>> running as a normal user rather than root or sudo, and if you are on a
>> remote machine, try using ssh -X to enable X11 forwarding. We will
>> need to know more about exactly what you are doing to help.
> 
> For remote access you also need to allow the remote machine to access 
> the display via "xhost +name" on the local machine.
> 
Well, I can assure you that I am neither working as root, I might be a 
newbie to matplotlib but not to linux, nor have any problem with the 
display. This problem is happening in both machines, remote (ssh -X, for 
sure, I've tested several times) and local, so no ssh conection. Anyway, 
I'm going to test a few more things and will let you know what happens.
AR
From: Alan G I. <ai...@am...> - 2008年07月16日 23:54:33
> On Wed, Jul 16, 2008 at 5:51 PM, Christopher Barker wrote:
>> I'd like to see the Delaunay stuff included -- in fact, 
>> you could contour irregular data directly using Delaunay 
>> triangulation. 
On 2008年7月16日, John Hunter apparently wrote:
> I'd love to see it included to -- I believe the problem is finding a 
> good code that is BSD compatible. 
I have not been following this thread so sorry if this 
proves irrelevant.
I assume you know of Robert Kern's code?
<URL:http://cours-info.iut-bm.univ-fcomte.fr/docs/python/scipy/scipy.sandbox.delaunay-module.html>
Cheers,
Alan Isaac
From: John H. <jd...@gm...> - 2008年07月16日 23:51:26
On Wed, Jul 16, 2008 at 5:51 PM, Christopher Barker
<Chr...@no...> wrote:
> In there, is says that MPL does not have this functionality built in --
> is that still true?
>
> If so, I'd like to see the Delaunay stuff included -- in fact, you could
> contour irregular data directly using Delaunay triangulation.
I'd love to see it included to -- I believe the problem is finding a
good code that is BSD compatible.
JDH
From: Christopher B. <Chr...@no...> - 2008年07月16日 22:49:46
Oz Nahum wrote:
> What I want to do plot is a cross section, and there is no easy way to 
> extrapulate between points. Not in excell and not in matlab.
I hope you mean interpolate -- extrapolation is fraught with danger!
> here is a simplification:
> 
> 
> distance
> _____________________________________________________
> |
> | x x
> | x x x
> |
> | y y y y 
> y y
> | 
> | z 
> | z z 
> z z 
> |
> |
> Now I want to draw contours between the x's y's and z's. This will 
> allow me to create very quickly lots' of graph of temp. prfiles of the 
> gulf.
OK, it looks like what you've got is some data on an irregularly spaced 
grid, in x.y space. To draw a contour plot of that data, you need to 
interpolate it onto a regular grid. Here is wiki page about that:
http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
In there, is says that MPL does not have this functionality built in -- 
is that still true?
If so, I'd like to see the Delaunay stuff included -- in fact, you could 
contour irregular data directly using Delaunay triangulation.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Alan G I. <ai...@am...> - 2008年07月16日 22:39:07
On 2008年7月16日, Michael Droettboom apparently wrote:
> [Attachment: dolphin.py : TEXT/PLAIN, 62 lines] 
I have to say, I was completely unaware of the path.Path 
capability of Matplotlib, but even if I had known of it, 
I would not have thought of how to exploit it this way.
Even though this was intended to be just for fun,
I hope it will be added to the examples.
Thanks!
Alan Isaac
From: Christopher B. <Chr...@no...> - 2008年07月16日 22:35:15
Oz Nahum wrote:
> I still get this error
> Traceback (most recent call last):
> File "yael.py", line 24, in <module>
> x = x.transpose()
> AttributeError: 'tuple' object has no attribute 'transpose'
as someone suggested, you really want to read up on numpy -- the 
transpose method is a method of numpy arrays. numpy arrays are kind of 
like Matlab matrixes, only more powerful and flexible. MPL is using 
numpy arrays inside anyway.
> and one more thing I discovered. the Data points that are ploted are not 
> temperature... this are the depth:distance coordinates.
if you have a contour plot, you have depth,distance as your x,y 
coordinates, with the temp value shown by the contours How did you 
expect to plot temp on top of that?
> I am a lost case about reading tutorial at the moment.
> I am in a middle of a very intense course, and they expect us to do 
> crazy stuff with matlab. so it's either that or solving with python. 
Either way, there is not choice but to learn a bit first! As hard as 
this is, you're right trying to do all your computation and plotting 
with with a spreadsheet is a nightmare -- you'll be glad you've learned it!
Have you read the MPL docs -- there's a lot of good, simple examples in 
there:
http://matplotlib.sourceforge.net/users_guide_0.98.1.pdf
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Oz N. <na...@gm...> - 2008年07月16日 21:54:49
So, after mailing all the previous mails, I've thought maybe I'm not asking
the right question.
What I want to do plot is a cross section, and there is no easy way to
extrapulate between points. Not in excell and not in matlab.
here is a simplification:
 distance
 _____________________________________________________
 |
 | x x
 | x x x
 |
 | y y y y
y y
 |
 | z
 | z z
z z
 |
 |
suppose the letters represent the temps: 29, 26, 23 deg. cel. and the
unmarked y axis is depth.
Now I want to draw contours between the x's y's and z's. This will allow me
to create very quickly lots' of graph of temp. prfiles of the gulf.
Many thanks, again. Oz
From: Chee S. L. <che...@gm...> - 2008年07月16日 21:41:48
Hello,
I'm pretty new to matplotlib, so please bear with me.
I am writing an application that includes a hexagonally binned scatter
plot that updates periodically, up to a couple times a second. My
current approach is clearing axes.collections, calling hexbin() with
the updated data, and then calling canvas.draw(). It works, but it is
entirely too slow. I would like to implement the blitting animation
technique shown in the matplotlib cookbook, but the collection object
returned by hexbin() doesn't seem to have any sort of set_data method
to update the data. Any suggestions?
I am using the wxPython GUI tookit, and FigureCanvasWxAgg.
Thanks,
Chee Sing Lee
From: Oz N. <na...@gm...> - 2008年07月16日 21:21:10
Dear Mike,
I really laughed. Many thanks. It's almost to late for me to really
understand the code now.
But some how you managed to throw in some stuff that can help:
you've made what I've wanted except for the dolphin.
I am sorry about the exagerating, but everybody here keep talking about this
young dolphin that keeps swimming around the reef here (I am in Eilat,
northren tip of Gulf of Aqaba).
Anyways, many thanks for you people trying to help.
Oz.
On Thu, Jul 17, 2008 at 12:12 AM, Michael Droettboom <md...@st...>
wrote:
> Oz Nahum wrote:
>
>> I am mostly frustrated with documentation writers who write very nice
>> tutorials describing how to plot completely unusfull graphs of spheres
>> inside loops and a dolphin swimming in the middle.
>>
> I'm sorry. I just couldn't resist writing a tutorial example for this.
> Please take it in the spirit of fun it was intended.
>
> Mike
>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
>
> import matplotlib.pyplot as plt
> from matplotlib.patches import Circle, PathPatch
> from matplotlib.path import Path
> from matplotlib.transforms import Affine2D
> import numpy as np
>
> r = np.random.rand(50)
> t = np.random.rand(50) * np.pi * 2.0
> x = r * np.cos(t)
> y = r * np.sin(t)
>
> fig = plt.figure(figsize=(6,6))
> ax = plt.subplot(111)
> circle = Circle((0, 0), 1, facecolor=(0,0,0.8),
> edgecolor=(0,0.8,0.8), linewidth=3, alpha=0.5)
> ax.add_patch(circle)
>
> plt.plot(x, y, 'o', color=(0.9, 0.9, 1.0), alpha=0.8)
>
> # Dolphin from OpenClipart library by Andy Fitzsimon
> # <cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
> # <cc:permits rdf:resource="
> http://web.resource.org/cc/Reproduction"/>
> # <cc:permits rdf:resource="
> http://web.resource.org/cc/Distribution"/>
> # <cc:permits rdf:resource="
> http://web.resource.org/cc/DerivativeWorks"/>
> # </cc:License>
>
> dolphin = """
> M -0.59739425,160.18173 C -0.62740401,160.18885 -0.57867129,160.11183
> -0.57867129,160.11183 C -0.57867129,160.11183 -0.5438361,159.89315
> -0.39514638,159.81496 C -0.24645668,159.73678 -0.18316813,159.71981
> -0.18316813,159.71981 C -0.18316813,159.71981 -0.10322971,159.58124
> -0.057804323,159.58725 C -0.029723983,159.58913 -0.061841603,159.60356
> -0.071265813,159.62815 C -0.080250183,159.65325 -0.082918513,159.70554
> -0.061841203,159.71248 C -0.040763903,159.7194 -0.0066711426,159.71091
> 0.077336307,159.73612 C 0.16879567,159.76377 0.28380306,159.86448
> 0.31516668,159.91533 C 0.3465303,159.96618 0.5011127,160.1771
> 0.5011127,160.1771 C 0.63668998,160.19238 0.67763022,160.31259
> 0.66556395,160.32668 C 0.65339985,160.34212 0.66350443,160.33642
> 0.64907098,160.33088 C 0.63463742,160.32533 0.61309688,160.297
> 0.5789627,160.29339 C 0.54348657,160.28968 0.52329693,160.27674
> 0.50728856,160.27737 C 0.49060916,160.27795 0.48965803,160.31565
> 0.46114204,160.33673 C 0.43329696,160.35786 0.4570711,160.39871
> 0.43309565,160.40685 C 0.4105108,160.41442 0.39416631,160.33027
> 0.3954995,160.2935 C 0.39683269,160.25672 0.43807996,160.21522
> 0.44567915,160.19734 C 0.45327833,160.17946 0.27946869,159.9424
> -0.061852613,159.99845 C -0.083965233,160.0427 -0.26176109,160.06683
> -0.26176109,160.06683 C -0.30127962,160.07028 -0.21167141,160.09731
> -0.24649368,160.1011 C -0.32642366,160.11569 -0.34521187,160.06895
> -0.40622293,160.0819 C -0.467234,160.09485 -0.56738444,160.17461
> -0.59739425,160.18173
> """
>
> vertices = []
> codes = []
> parts = dolphin.split()
> i = 0
> code_map = {
> 'M': (Path.MOVETO, 1),
> 'C': (Path.CURVE4, 3),
> 'L': (Path.LINETO, 1)
> }
>
> while i < len(parts):
> code = parts[i]
> path_code, npoints = code_map[code]
> codes.extend([path_code] * npoints)
> vertices.extend([[float(x) for x in y.split(',')] for y in
> parts[i+1:i+npoints+1]])
> i += npoints + 1
> vertices = np.array(vertices, np.float)
> vertices[:,1] -= 160
>
> dolphin_path = Path(vertices, codes)
> dolphin_patch = PathPatch(dolphin_path, facecolor=(0.6, 0.6, 0.6),
> edgecolor=(0.0, 0.0, 0.0))
> ax.add_patch(dolphin_patch)
>
> vertices = Affine2D().rotate_deg(60).transform(vertices)
> dolphin_path2 = Path(vertices, codes)
> dolphin_patch2 = PathPatch(dolphin_path2, facecolor=(0.5, 0.5, 0.5),
> edgecolor=(0.0, 0.0, 0.0))
> ax.add_patch(dolphin_patch2)
>
> plt.show()
>
>
From: Michael D. <md...@st...> - 2008年07月16日 21:12:21
Attachments: dolphin.py
Oz Nahum wrote:
> I am mostly frustrated with documentation writers who write very nice 
> tutorials describing how to plot completely unusfull graphs of spheres 
> inside loops and a dolphin swimming in the middle.
I'm sorry. I just couldn't resist writing a tutorial example for this. 
Please take it in the spirit of fun it was intended.
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Oz N. <na...@gm...> - 2008年07月16日 20:34:49
I still get this error
Traceback (most recent call last):
 File "yael.py", line 24, in <module>
 x = x.transpose()
AttributeError: 'tuple' object has no attribute 'transpose'
and one more thing I discovered. the Data points that are ploted are not
temperature... this are the depth:distance coordinates.
I am a lost case about reading tutorial at the moment.
I am in a middle of a very intense course, and they expect us to do crazy
stuff with matlab. so it's either that or solving with python. I'll do read
it when I have time...
I am mostly frustrated with documentation writers who write very nice
tutorials describing how to plot completely unusfull graphs of spheres
inside loops and a dolphin swimming in the middle.
Come on, this is not what users need. I am talking about what many students
feel. We need real tutorials, this why I wrote my own little tutorial here
http://www.tabula0rasa.org/?p=21
but that's not enough.
sorry about making so much fuss in the mailing list and crying my hearts
out, but I thought since I know python it's worth trying this and not
mathlab
Oz
On Wed, Jul 16, 2008 at 11:20 PM, John Hunter <jd...@gm...> wrote:
> On Wed, Jul 16, 2008 at 3:18 PM, Oz Nahum <na...@gm...> wrote:
> >>You can transpose your inputs. For numpy arrays: x = x.transpose()
> >
> > i wrote:
> > for np arrays: x = x.transpose()
> >
> > but I still get a syntax error.
>
> umm.... that was english, not python. They python is
>
> x = x.transpose()
>
> I know you are anxious to get results fast, but I suggest taking a
> deep breath and doing a little reading on the numpy and matplotlib
> tutorials linked on theor respective websites....
>
> JDH
>
From: John H. <jd...@gm...> - 2008年07月16日 20:20:33
On Wed, Jul 16, 2008 at 3:18 PM, Oz Nahum <na...@gm...> wrote:
>>You can transpose your inputs. For numpy arrays: x = x.transpose()
>
> i wrote:
> for np arrays: x = x.transpose()
>
> but I still get a syntax error.
umm.... that was english, not python. They python is
 x = x.transpose()
I know you are anxious to get results fast, but I suggest taking a
deep breath and doing a little reading on the numpy and matplotlib
tutorials linked on theor respective websites....
JDH
From: Tim M. <tim...@gm...> - 2008年07月16日 20:19:37
Oz Nahum schrieb:
> Hi,
> I want to draw a contour plot which uses data from files. I know how to 
> import the files, so it's not the main issue.
I was discussion a similar issue with Jeff this week.
Take a look at the thread:
http://news.gmane.org/gmane.comp.python.matplotlib.general
Unfortunately, I had to focus on other things and had to postpone the 
development of my script...
From: Oz N. <na...@gm...> - 2008年07月16日 20:18:35
>You can transpose your inputs. For numpy arrays: x = x.transpose()
i wrote:
for np arrays: x = x.transpose()
but I still get a syntax error.
> > Also, one more thing, I can't find how to expand the borders of the plot,
> > say from 350 to 400
> > (same for depth) I tried usig xlim and ylim(0,900) but no result.
>
> >Subsequent calls to plot will call the autoscaler, so either you need
> >to set the xlim *after* all the plotting commands or turn off
> >autoscaling entirely by passing the autoscale_on=False property to the
> >axes, eg
>
> >plt.gca().set_autoscale_on(False)
>
That does for the one of the problems.
And I still haven't manage to plot the 4th series.
still many thanks...
hope I can figure this out...
From: John H. <jd...@gm...> - 2008年07月16日 20:11:03
On Wed, Jul 16, 2008 at 2:58 PM, Oz Nahum <na...@gm...> wrote:
> Here is why the contours are wrong:
> they are ploted verticaly, while I think, it is more common to draw temp.
> contours in oceanography when the are horizontal.
You can transpose your inputs. For numpy arrays: x = x.transpose()
> Also, one more thing, I can't find how to expand the borders of the plot,
> say from 350 to 400
> (same for depth) I tried usig xlim and ylim(0,900) but no result.
Subsequent calls to plot will call the autoscaler, so either you need
to set the xlim *after* all the plotting commands or turn off
autoscaling entirely by passing the autoscale_on=False property to the
axes, eg
plt.gca().set_autoscale_on(False)
From: Oz N. <na...@gm...> - 2008年07月16日 19:58:48
Here is why the contours are wrong:
they are ploted verticaly, while I think, it is more common to draw temp.
contours in oceanography when the are horizontal.
Also, one more thing, I can't find how to expand the borders of the plot,
say from 350 to 400
(same for depth) I tried usig xlim and ylim(0,900) but no result.
Here is my code now, I can't really get it, ha ?
another issue is that I've added anoter temp. series but it won't show it. I
still see 3 rows.
from matplotlib import pyplot as plt
from pylab import *
temperature=[
 [9,8,6],
 [9,7,6],
 [9,7,6],
 [9,6,6]
]
distance = (0,200,350)
depth = (100,250,250,700)
x = distance
y = depth
z = temperature
#m = plt.contourf(x,y,z)
m = plt.contour(x,y,z)
ylabel('Depth')
xlabel('Distance')
ylim(0,1200)
#plt.xlim(0,500)
plt.gca().invert_yaxis()
#plt.colorbar(m)
import numpy as np
X, Y = np.meshgrid(x,y)
#plt.hold(True) # probably not necessary
plt.plot(X,Y, 'o')
plt.show(m)
On Wed, Jul 16, 2008 at 10:28 PM, Eric Firing <ef...@ha...> wrote:
> Oz Nahum wrote:
>
>> Hi Eric,
>> really thanks for your help so far. I am doing a quick short course, and
>> I'll do the examples later.
>> I've fixed the code, here it is:
>>
>> from matplotlib import pyplot as plt
>> temperature=[
>> [10,8,6],
>> [9,7,5],
>> [8,7,4]
>> ]
>>
>> distance = (100,200,300)
>> depth = (100,300,700)
>>
>> x = distance
>> y = depth
>> z = temperature
>>
>> m = plt.contourf(x,y,z)
>> plt.gca().invert_yaxis()
>> plt.colorbar(m)
>> plt.show(m)
>>
>> the trouble now that the contours seems wrong... and my question still
>> stands. I'd like to do the plot as said: contours + series, can you show me
>> where I'm wrong ?
>>
>
> The plot looks right to me--I see 4 degrees in the lower RH corner, 300
> distance units and 700 depth units. Why do you say the contours seem
> wrong?
>
> As for plotting the "series", what do you mean? Put circles on the data
> points? Then include something like this, after the call to contourf:
>
> import numpy as np
> X, Y = np.meshgrid(x,y)
> plt.hold(True) # probably not necessary
> plt.plot(X,Y, 'o')
>
>
>
> Eric
>
>>
>> thanks, Oz
>>
>>
>> On Wed, Jul 16, 2008 at 9:37 PM, Eric Firing <ef...@ha... <mailto:
>> ef...@ha...>> wrote:
>>
>> Oz Nahum wrote:
>>
>> Ok, I played with it a little bit.
>>
>> Here is what I know:
>> importing the data is not a big issue, I aready wrote a tutorial
>> about it here:
>> http://www.tabula0rasa.org/?p=21
>>
>> here is a sample code I wrote.
>> from matplotlib import pyplot as plt
>> from pylab import *
>> temperature=[
>> [1,3,4],
>> [2,4,5],
>> [6,3,2]
>> ]
>>
>> distance = (100,200,300)
>> depth = (10,30,50)
>>
>> plt.colorbar()
>> plt.contourf(distance,depth,temperature)
>> plt.gca().invert_yaxis()
>> plt.show()
>>
>>
>>
>> Can I plot the dots as different series on top of the contours ?
>>
>>
>> First you have to make your basic example work; what you posted
>> above does not.
>> 1) For an example like this, use a different number of points in the
>> x and y directions, to make it clear how the arrays are oriented.
>> 2) The colorbar command must *follow* the contourf command.
>> 3) Make your test temperature profiles more reasonable, i.e.
>> temperature decreasing with depth, so you can see whether your plot
>> is doing the right thing.
>> 4) Omit the "from pylab import *"
>> 5) Once you start doing real work, you will need numpy. The
>> suggested import syntax is "import numpy as np".
>> 6) Study the examples that come with mpl.
>>
>> Eric
>>
>>
>>
>
From: Eric F. <ef...@ha...> - 2008年07月16日 19:28:30
Oz Nahum wrote:
> Hi Eric,
> really thanks for your help so far. I am doing a quick short course, and 
> I'll do the examples later.
> I've fixed the code, here it is:
> 
> from matplotlib import pyplot as plt
> temperature=[
> [10,8,6],
> [9,7,5],
> [8,7,4]
> ]
> 
> distance = (100,200,300)
> depth = (100,300,700)
> 
> x = distance
> y = depth
> z = temperature
> 
> m = plt.contourf(x,y,z)
> plt.gca().invert_yaxis()
> plt.colorbar(m)
> plt.show(m)
> 
> the trouble now that the contours seems wrong... and my question still 
> stands. I'd like to do the plot as said: contours + series, can you show 
> me where I'm wrong ?
The plot looks right to me--I see 4 degrees in the lower RH corner, 300 
 distance units and 700 depth units. Why do you say the contours seem 
wrong?
As for plotting the "series", what do you mean? Put circles on the data 
points? Then include something like this, after the call to contourf:
import numpy as np
X, Y = np.meshgrid(x,y)
plt.hold(True) # probably not necessary
plt.plot(X,Y, 'o')
Eric
> 
> thanks, Oz
> 
> On Wed, Jul 16, 2008 at 9:37 PM, Eric Firing <ef...@ha... 
> <mailto:ef...@ha...>> wrote:
> 
> Oz Nahum wrote:
> 
> Ok, I played with it a little bit.
> 
> Here is what I know:
> importing the data is not a big issue, I aready wrote a tutorial
> about it here:
> http://www.tabula0rasa.org/?p=21
> 
> here is a sample code I wrote.
> from matplotlib import pyplot as plt
> from pylab import *
> temperature=[
> [1,3,4],
> [2,4,5],
> [6,3,2]
> ]
> 
> distance = (100,200,300)
> depth = (10,30,50)
> 
> plt.colorbar()
> plt.contourf(distance,depth,temperature)
> plt.gca().invert_yaxis()
> plt.show()
> 
> 
> 
> Can I plot the dots as different series on top of the contours ?
> 
> 
> First you have to make your basic example work; what you posted
> above does not.
> 1) For an example like this, use a different number of points in the
> x and y directions, to make it clear how the arrays are oriented.
> 2) The colorbar command must *follow* the contourf command.
> 3) Make your test temperature profiles more reasonable, i.e.
> temperature decreasing with depth, so you can see whether your plot
> is doing the right thing.
> 4) Omit the "from pylab import *"
> 5) Once you start doing real work, you will need numpy. The
> suggested import syntax is "import numpy as np".
> 6) Study the examples that come with mpl.
> 
> Eric
> 
> 
From: Oz N. <na...@gm...> - 2008年07月16日 18:47:48
Hi Eric,
really thanks for your help so far. I am doing a quick short course, and
I'll do the examples later.
I've fixed the code, here it is:
from matplotlib import pyplot as plt
temperature=[
 [10,8,6],
 [9,7,5],
 [8,7,4]
]
distance = (100,200,300)
depth = (100,300,700)
x = distance
y = depth
z = temperature
m = plt.contourf(x,y,z)
plt.gca().invert_yaxis()
plt.colorbar(m)
plt.show(m)
the trouble now that the contours seems wrong... and my question still
stands. I'd like to do the plot as said: contours + series, can you show me
where I'm wrong ?
thanks, Oz
On Wed, Jul 16, 2008 at 9:37 PM, Eric Firing <ef...@ha...> wrote:
> Oz Nahum wrote:
>
>> Ok, I played with it a little bit.
>>
>> Here is what I know:
>> importing the data is not a big issue, I aready wrote a tutorial about it
>> here:
>> http://www.tabula0rasa.org/?p=21
>>
>> here is a sample code I wrote.
>> from matplotlib import pyplot as plt
>> from pylab import *
>> temperature=[
>> [1,3,4],
>> [2,4,5],
>> [6,3,2]
>> ]
>>
>> distance = (100,200,300)
>> depth = (10,30,50)
>>
>> plt.colorbar()
>> plt.contourf(distance,depth,temperature)
>> plt.gca().invert_yaxis()
>> plt.show()
>>
>>
>>
>> Can I plot the dots as different series on top of the contours ?
>>
>
> First you have to make your basic example work; what you posted above does
> not.
> 1) For an example like this, use a different number of points in the x and
> y directions, to make it clear how the arrays are oriented.
> 2) The colorbar command must *follow* the contourf command.
> 3) Make your test temperature profiles more reasonable, i.e. temperature
> decreasing with depth, so you can see whether your plot is doing the right
> thing.
> 4) Omit the "from pylab import *"
> 5) Once you start doing real work, you will need numpy. The suggested
> import syntax is "import numpy as np".
> 6) Study the examples that come with mpl.
>
> Eric
>
From: Eric F. <ef...@ha...> - 2008年07月16日 18:38:15
Oz Nahum wrote:
> Ok, I played with it a little bit.
> 
> Here is what I know:
> importing the data is not a big issue, I aready wrote a tutorial about 
> it here:
> http://www.tabula0rasa.org/?p=21
> 
> here is a sample code I wrote.
> from matplotlib import pyplot as plt
> from pylab import *
> temperature=[
> [1,3,4],
> [2,4,5],
> [6,3,2]
> ]
> 
> distance = (100,200,300)
> depth = (10,30,50)
> 
> plt.colorbar()
> plt.contourf(distance,depth,temperature)
> plt.gca().invert_yaxis()
> plt.show()
> 
> 
> 
> Can I plot the dots as different series on top of the contours ?
First you have to make your basic example work; what you posted above 
does not.
1) For an example like this, use a different number of points in the x 
and y directions, to make it clear how the arrays are oriented.
2) The colorbar command must *follow* the contourf command.
3) Make your test temperature profiles more reasonable, i.e. temperature 
decreasing with depth, so you can see whether your plot is doing the 
right thing.
4) Omit the "from pylab import *"
5) Once you start doing real work, you will need numpy. The suggested 
import syntax is "import numpy as np".
6) Study the examples that come with mpl.
Eric
8 messages has been excluded from this view by a project administrator.

Showing results of 395

<< < 1 .. 5 6 7 8 9 .. 16 > >> (Page 7 of 16)
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 によって変換されたページ (->オリジナル) /