Re: [Matplotlib-users] Selectable contour(f) divisions
On Friday 12 February 2010 15:11:17 Bruce Ford wrote: > Thanks for this. I didn't realize that N could be an array and > contour would know that these are the levels desired. > > I found similar in an example, but not in the contour documentation. Just a remark: I use the help of IPython to investigate the doc-strings of matplotlib-functions. The input "contour?" tells me :: contour(Z,V) contour(X,Y,Z,V) draw contour lines at the values specified in sequence *V* Kind regards, Matthias > Thanks so much! > > Bruce > On Fri, Feb 12, 2010 at 7:29 AM, Matthias Michler > > wrote: > > Hi Bruce, > > > > why don't you use contour as in the following ;-) > > > > contour(X,Y,Z,V) > > # -> draw contour lines at the values specified in sequence *V* > > > > like in > > > > x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50)) > > z = x**4 - x**2 + np.sin(y) > > contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8]) > > > > Kind regards, > > Matthias > > > > On Thursday 11 February 2010 21:58:15 Bruce Ford wrote: > >> In using the contour as in: > >> > >> contour(X,Y,Z,N) > >> > >> N is a number of automatically chosen levels. > >> > >> I would like to contour based on data divisions. > >> > >> For instance, perhaps I'd like to use a contour or color-fill > >> (contourf) every 2 units. I'm not seeing how to accomplish this. Any > >> points in the right direction would be appreciated. > >> > >> Thanks! > >> > >> Bruce -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Selectable contour(f) divisions
Hi Bruce, why don't you use contour as in the following ;-) contour(X,Y,Z,V) # -> draw contour lines at the values specified in sequence *V* like in x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50)) z = x**4 - x**2 + np.sin(y) contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8]) Kind regards, Matthias On Thursday 11 February 2010 21:58:15 Bruce Ford wrote: > In using the contour as in: > > contour(X,Y,Z,N) > > N is a number of automatically chosen levels. > > I would like to contour based on data divisions. > > For instance, perhaps I'd like to use a contour or color-fill > (contourf) every 2 units. I'm not seeing how to accomplish this. Any > points in the right direction would be appreciated. > > Thanks! > > Bruce -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] selecting part of a contour to plot
Jon, One thing you can do is to manually specify the levels to contour for in the contour call, or just specify the number of contours (and contour() will figure out the levels for you). The fourth argument to contour() allows you to give a sequence of values (or an integer) for the isopleths. So, if you want just one line (but have it chosen automatically): contour(x, y, z, 1) If you want a contour to always be for the value of 4.5, for example, then: contour(x, y, z, [4.5]) Should do the trick. I hope that helps, Ben Root On Tue, Jun 22, 2010 at 1:46 PM, Jonathan Slavin wrote: > To all: > > I'm making a plot with an image and a contour on it. I use only one > level in the call to contour, but it results in two distinct contours, > an inner closed one and an outer open one. I want to plot only the > outer piece. How might I go about that? I've been looking at the > properties of the ContourSet object returned by the call to contour but > can't find anything useful yet. Is there an attribute of ContourSet > objects that contains the (x,y) values for the contour? Is there some > way to see that a ContourSet object has separate pieces? > > Any help would be appreciated. > > Thanks, > Jon > > > > -- > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Selectable contour(f) divisions
Thanks for this. I didn't realize that N could be an array and contour would know that these are the levels desired. I found similar in an example, but not in the contour documentation. Thanks so much! Bruce --- Bruce W. Ford Clear Science, Inc. br...@clearscienceinc.com bruce.w.ford@navy.smil.mil http://www.ClearScienceInc.com Phone/Fax: 904-379-9704 8241 Parkridge Circle N. Jacksonville, FL 32211 Skype: bruce.w.ford Google Talk: for...@gmail.com On Fri, Feb 12, 2010 at 7:29 AM, Matthias Michler wrote: > Hi Bruce, > > why don't you use contour as in the following ;-) > > contour(X,Y,Z,V) > # -> draw contour lines at the values specified in sequence *V* > > like in > > x, y = np.meshgrid(np.linspace(0, 1, 100), np.linspace(0, 1, 50)) > z = x**4 - x**2 + np.sin(y) > contour(x, y, z, [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8]) > > Kind regards, > Matthias > > On Thursday 11 February 2010 21:58:15 Bruce Ford wrote: >> In using the contour as in: >> >> contour(X,Y,Z,N) >> >> N is a number of automatically chosen levels. >> >> I would like to contour based on data divisions. >> >> For instance, perhaps I'd like to use a contour or color-fill >> (contourf) every 2 units. I'm not seeing how to accomplish this. Any >> points in the right direction would be appreciated. >> >> Thanks! >> >> Bruce > > > -- > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] selecting part of a contour to plot
Actually, I just re-read your original message and noticed that you were specifying your levels (I believe). The double set of contours depends on what your values are. If you want to make absolutely sure that there aren't extra lines, you could contour a boolean array: contour(x, y, z > 4.5, [0, 1]) That should do the trick as well (assuming you know the level that you want the isopleth for). Ben Root On Tue, Jun 22, 2010 at 6:27 PM, Benjamin Root wrote: > Jon, > > One thing you can do is to manually specify the levels to contour for in > the contour call, or just specify the number of contours (and contour() will > figure out the levels for you). The fourth argument to contour() allows you > to give a sequence of values (or an integer) for the isopleths. So, if you > want just one line (but have it chosen automatically): > > contour(x, y, z, 1) > > If you want a contour to always be for the value of 4.5, for example, then: > > contour(x, y, z, [4.5]) > > Should do the trick. > > I hope that helps, > Ben Root > > > > > On Tue, Jun 22, 2010 at 1:46 PM, Jonathan Slavin > wrote: > >> To all: >> >> I'm making a plot with an image and a contour on it. I use only one >> level in the call to contour, but it results in two distinct contours, >> an inner closed one and an outer open one. I want to plot only the >> outer piece. How might I go about that? I've been looking at the >> properties of the ContourSet object returned by the call to contour but >> can't find anything useful yet. Is there an attribute of ContourSet >> objects that contains the (x,y) values for the contour? Is there some >> way to see that a ContourSet object has separate pieces? >> >> Any help would be appreciated. >> >> Thanks, >> Jon >> >> >> >> -- >> ThinkGeek and WIRED's GeekDad team up for the Ultimate >> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the >> lucky parental unit. See the prize list and enter to win: >> http://p.sf.net/sfu/thinkgeek-promo >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Drawing a single contour line
Hi there, I can draw a single contour line in MATLAB using contour(z, [i i]) however, contour(z, [i, i]) using matplotlib gives an error. In fact any plot that plots a single line (i.e. contour(z, 1)) also gives an error as follows, TypeError: unhashable type: 'numpy.ndarray' How do I draw a single contour line using matplotlib? regards, Brendan -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Different contours in contour and contourf
Yannick Copin wrote: > Hi, > > running the simple test code: > > from pylab import * > X, Y = meshgrid(linspace(-3,3,11),linspace(-3,3,11)) > Z = randn(*X.shape) > lev = linspace(Z.min(),Z.max(),11)[1:-1] > contourf(X,Y,Z, lev, extend='both') > contour(X,Y,Z, lev, colors='k') > show() > > you will probably notice that the 'contourf' contours are not always > exactly the sames as the 'contour' contours. Why is it so? Don't contour > and contourf use the same contour constructor? The same overall routine is used for contour as for contourf, but the contour tracing operation is not identical. Tracing a filled contour is much more complicated--that is probably why it is so hard to find filled contour routines. I suspect that whoever wrote the original code we are using wrote the line contour version first, then had to add quite a bit of logic and code to get it to make filled contours. Now, you may be wondering why we can't simply use the boundary of the filled regions for the lines as well, to guarantee they are the same. The reason is that filled contour boundaries include cuts connecting inner and outer contours, and also inner boundaries (edges of masked regions--except when affected by a bug) and the outer boundaries of the domain). It might be possible to simply exclude those line segments from the line contours, but it is not clear to me that the effort would be well-spent. I think that the differences illustrated in your example will occur almost entirely in pathologically ambiguous cases, but it is also possible that they reflect actual bugs or shortcomings of the algorithms used. Understanding the logic and tracing the code path in the present cntr.c is difficult; I have tried but failed to figure out and correct the interior masked region bug in contourf. If a better core contour routine with a suitable license could be found and substituted for the present one, that would be very nice. I have searched many times without turning anything up. Eric - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [Fwd: Re: contour & colorbar...]
--- Begin Message --- fred wrote: Hi, Please look at the short example attached showing the issue. I want to display only one contour line, with value 0.8. Obviously, the color associated with this contour line is bad (blue instead of red color). I think the reason is that the contour has its own colormap, so for only one value, the color is blue. I don't see anything about this issue in the contour help. How can I fix this ? At first I thought you wanted to draw a contour line on both the image and the colorbar, which you would do this way: imshow(a) cb = colorbar() cs = contour(a, [0.8]) cb.add_lines(cs) But then I looked at your message again and realized this is not what you want. If you do what you seem to be saying you want to do, you will end up with a nearly invisible line: if you use color mapping to determine the color of the contour line, and you put it on the image, it will of course not stand out very well. Here is how you would do it: im = imshow(a) cb = colorbar() cs = contour(a, [0.8], norm = im.norm, cmap=im.cmap) cb.add_lines(cs) Is this in fact what you want? If nothing else, it illustrates how you can control the colormap and associated norm (scaling function) used by contour. Eric Thanks in advance. Cheers, #! /usr/bin/env python from scipy import * from pylab import * x, y = ogrid[-3:3:10*1j,-3:3:10*1j] a = cos(x)*sin(y) imshow(a) colorbar() contour(a, [0.8]) show() - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users --- End Message --- - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Drawing a single contour line
On Mon, Nov 2, 2009 at 3:19 PM, Brendan Arnold wrote: > Hi there, > > I can draw a single contour line in MATLAB using > > contour(z, [i i]) > > however, > > contour(z, [i, i]) > > using matplotlib gives an error. In fact any plot that plots a single > line (i.e. contour(z, 1)) also gives an error as follows, > > TypeError: unhashable type: 'numpy.ndarray' > > How do I draw a single contour line using matplotlib? I've used: ax.contour(R, F, dR, levels=[0]) -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Coordinates of contour lines
Hi All, I need to use the coordinates of a contour line for further calculations. Is there a simple way to get the x,y coordinates from a contour object or otherwise? i.e. I have (x,y,z) coordinates and have created a contour map from these. I need the (x,y) coordinates of the contour line with value z0. Cheers Ewald -- This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] selecting part of a contour to plot
contour creates list of LineCollection objects (per each level I suppose) which is stored in "collections" attribute. For example, cntr = contour(A, levels) then cntr.collections[i] is a LineCollection objects that is associated with levels[i]. And you can change colors of each line in the LineCollection object with set_edgecolors method. So, assuming that there is two contour lines for the first level. cntr.collections[0].set_edgecolors(["none", "r"]) will change the color of the first contour to "none" (i.e., not drawn) and the second one to red. But you need to figure out which one is the one you want. IHTH, -JJ On Tue, Jun 22, 2010 at 2:46 PM, Jonathan Slavin wrote: > To all: > > I'm making a plot with an image and a contour on it. I use only one > level in the call to contour, but it results in two distinct contours, > an inner closed one and an outer open one. I want to plot only the > outer piece. How might I go about that? I've been looking at the > properties of the ContourSet object returned by the call to contour but > can't find anything useful yet. Is there an attribute of ContourSet > objects that contains the (x,y) values for the contour? Is there some > way to see that a ContourSet object has separate pieces? > > Any help would be appreciated. > > Thanks, > Jon > > > -- > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting 2D Structured CFD Grids and contour plots
On 29 March 2013 20:15, Jeff Layton wrote: > Good afternoon, > > I'd like to be able to plot some 2D Structured CFD meshes > and contour plots (pressure, etc) using Matplotlib. I've > googled a little but does anyone have any pointers or > links to help get me started? > > Thanks! > > Jeff > The functions you want are 'contour' for contour line plots, and 'contourf' for filled contour plots. Start with http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.contour, which describes the contour function and includes example plots with source code. Ian -- Own the Future-Intel(R) Level Up Game Demo Contest 2013 Rise to greatness in Intel's independent game demo contest. Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour & colorbar...
Hi, Please look at the short example attached showing the issue. I want to display only one contour line, with value 0.8. Obviously, the color associated with this contour line is bad (blue instead of red color). I think the reason is that the contour has its own colormap, so for only one value, the color is blue. I don't see anything about this issue in the contour help. How can I fix this ? Thanks in advance. Cheers, -- http://scipy.org/FredericPetit #! /usr/bin/env python from scipy import * from pylab import * x, y = ogrid[-3:3:10*1j,-3:3:10*1j] a = cos(x)*sin(y) imshow(a) colorbar() contour(a, [0.8]) show() - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] selecting part of a contour to plot
Thanks to Benjamin Root and Jae-Joon Lee for their responses. The solution that I had come up with in the mean time is similar to Jae-Joon's suggestion. I did: c = contour(z,level,colors='k') xy = c.collections[0].get_paths()[0].vertices # produces (N,2) array of points plot(xy[:,0],xy[:,1],'w') c.collections[0].get_paths() returns a list of Path objects. These have the attribute vertices which contains the values used to draw the contour. Jae-Joon's method is a bit more straightforward than mine, though it's nice to know where those contour paths are stored. Jon On Tue, 2010-06-22 at 22:40 -0400, Jae-Joon Lee wrote: > contour creates list of LineCollection objects (per each level I > suppose) which is stored in "collections" attribute. For example, > > cntr = contour(A, levels) > > then > > cntr.collections[i] is a LineCollection objects that is associated > with levels[i]. > > And you can change colors of each line in the LineCollection object > with set_edgecolors method. > > So, assuming that there is two contour lines for the first level. > > cntr.collections[0].set_edgecolors(["none", "r"]) > > will change the color of the first contour to "none" (i.e., not drawn) > and the second one to red. > > But you need to figure out which one is the one you want. > > IHTH, > > -JJ > > > On Tue, Jun 22, 2010 at 2:46 PM, Jonathan Slavin > wrote: > > To all: > > > > I'm making a plot with an image and a contour on it. I use only one > > level in the call to contour, but it results in two distinct contours, > > an inner closed one and an outer open one. I want to plot only the > > outer piece. How might I go about that? I've been looking at the > > properties of the ContourSet object returned by the call to contour but > > can't find anything useful yet. Is there an attribute of ContourSet > > objects that contains the (x,y) values for the contour? Is there some > > way to see that a ContourSet object has separate pieces? > > > > Any help would be appreciated. > > > > Thanks, > > Jon > > > > > > -- > > ThinkGeek and WIRED's GeekDad team up for the Ultimate > > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > > lucky parental unit. See the prize list and enter to win: > > http://p.sf.net/sfu/thinkgeek-promo > > ___ > > Matplotlib-users mailing list > > Matplotlib-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- __ Jonathan D. Slavin Harvard-Smithsonian CfA jsla...@cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] labeling contours with roman numerals
I would guess: CS=contour(A,[50,]) CS.clabel(fmt=FormatFaker('I')) # Labels contour 50 with I CS=contour(A,[60,]) CS.clabel(fmt=FormatFaker('II')) # Labels contour 60 with II Or write a loop if you have many values. Mark On Dec 14, 2007 11:44 PM, Michael Hearne <[EMAIL PROTECTED]> wrote: > I've seen this, but I'm not clever enough to see how to extend that to > multiple levels - after all, I don't want to label every line with the same > string... > --Mike > On Dec 14, 2007, at 3:20 PM, Mark Bakker wrote: > > Michael - > > This trick for replacing contour labels with a string was posted a little > while back (by someone else):* > * > > class FormatFaker(object): >def __init__(self, str): self.str = str >def __mod__(self, stuff): return self.str > > A=arange(100).reshape(10,10) > CS=contour(A,[50,]) > CS.clabel(fmt=FormatFaker('Some String')) > > > > > > > From: Michael Hearne <[EMAIL PROTECTED] > > > Subject: [Matplotlib-users] labeling contours with roman numerals > > To: Matplotlib Users > > Message-ID: < [EMAIL PROTECTED]> > > Content-Type: text/plain; charset="us-ascii" > > > > Does a LineCollection generated by contour() have a property that > > holds the labels? I would like to label my contour lines with roman > > numerals, and cannot figure out how to get clabel to do that. > > > > Thanks, > > > > Mike > > > > > > > > > > > -- > Michael Hearne > [EMAIL PROTECTED] > (303) 273-8620 > USGS National Earthquake Information Center > 1711 Illinois St. Golden CO 80401 > Senior Software Engineer > Synergetics, Inc. > -- > > > - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Drawing a single contour line
From memory, you just need to make a length one list contour(z, [i]) Pierre Le 2 nov. 09 à 22:19, Brendan Arnold a écrit : > Hi there, > > I can draw a single contour line in MATLAB using > > contour(z, [i i]) > > however, > > contour(z, [i, i]) > > using matplotlib gives an error. In fact any plot that plots a single > line (i.e. contour(z, 1)) also gives an error as follows, > > TypeError: unhashable type: 'numpy.ndarray' > > How do I draw a single contour line using matplotlib? > > regards, > > Brendan > > -- > > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market > and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Omitting curves from a legend
Maybe I should make _nolegend_ the default for contour and contourf collections? Eric John Hunter wrote: > On 4/13/07, Bill Baxter <[EMAIL PROTECTED]> wrote: >> There are a couple things about legend that I'm finding a little >> irksome. Is there some better way to do this? >> >> 1) if you have a contour, legend() wants to add all the contours to >> the list. calling contour(...,label='_nolegend_') doesn't seem to >> help. > > You should be able to set the "_nolegend_" label property on the > contour set line collections like so: > > >>> cs = contour(...blah...) > > >>> for coll in cs.collections: > coll.set_label('_nolegend_') > > of use "setp" for the same purpose. > > >>> setp(cs.collections, label='_nolegend_') > > contour doesn't use the kwargs to set the line collection properties, > which is why it is not working in the contour commands. some plot > commands use the kwargs to update the artist properties that the plot > command creates, some do not, and the only way to know is the read the > individual docstrings of the commands. > > Let me know if this works because it is untested. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Orientation of contour-values
Hello, i've made a (filled) contour plot with matplotlib-pyplot. First i use contour() and after that contourf(). My question: the contour-values on the lines have all different orientations. Is it possible to align alle values horizontal (linke normal text)? Thanks, Sappy85 -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Orientation-of-contour-values-tp42829.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Combining pcolormesh and contour
Am Di 28 Feb 2012 19:23:14 CET schrieb Eric Firing: > On 02/28/2012 08:08 AM, Andreas H. wrote: >> Am 28.02.2012 18:56, schrieb Eric Firing: >>> On 02/28/2012 06:28 AM, Andreas H. wrote: >>>>>> On Tuesday, February 28, 2012, Andreas H. wrote: >>>>>> >>>>>>> Good morning, >>>>>>> >>>>>>> I'm creating the attached plot using pcolormesh(). What I would like to >>>>>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges. >>>>>>> >>>>>>> The problem is that when I use contour(), the lines drawn do not follow >>>>>>> the grid edges but seem to be interpolated somehow. >>>>>>> >>>>>>> Do you have an idea how to draw the contour lines following the grid >>>>>>> edges? >>>>>>> >>>>>>> Your insight is very much appreciated :) >>>>>>> >>>>>>> Cheers, >>>>>>> Andreas. >>>>>>> >>>>>> >>>>>> This is because of a subtle difference in how pcolor-like functions and >>>>>> contour-like functions work. I always forget which is which, but one >>>>>> assumes that the z value lies on the vertices of the grid while the >>>>>> other >>>>>> assumes that it lies in the middle of each grid point. This is why you >>>>>> see >>>>>> them slightly offset from each other. >>>>> >>>>> Thanks, Ben! >>>>> >>>>> To `pcolormesh`, I pass the *edges* of the grid: >>>>> >>>>> xbin = linspace(0, 12, nxbin + 1) >>>>> ybin = np.linspace(-90, 90, nybin + 1) >>>>> >>>>> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, >>>>> edgecolors='None', >>>>> vmin=-5, vmax=20) >>>>> >>>>> `contour`, however, wants the coordinates themselves. So I do >>>>> >>>>> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, >>>>> pdata.T, >>>>> [-2.5, 2.5]) >>>>> >>>>> Still, the outcome is, well, unexpected to me. Actually, no matter if >>>>> contour wants centres or edges, the actual behaviour seems strange. There >>>>> is some interpolation going on, apparently. The input `pdata` has shape >>>>> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid >>>>> movement in the x-direction. >>>>> >>>>> Any ideas? >>>> >>>> Okay, after some diving into matplotlib sources, I guess the interpolation >>>> comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So >>>> there seems to be no way to accomplish what I actually want with the >>>> current matplotlib API. Correct? >>>> >>>> If I wanted to do something about this, I would need to >>>> >>>> * implement a class `GriddedContourSet`, derived from `ContourSet`, where >>>> I implement the `_get_allsegs_and_allkinds` method appropriately. >>>> * add an additional keyword argument to `contour()` to make this gridded >>>> contourset an option when calling `contour()`. >>>> >>>> Is this all correct? If yes, I might start working on this if I get the >>>> time ... >>> >>> It is not at all clear to me what you want to do, as compared to what >>> contour does. Can you illustrate with an extremely simple example? >>> Maybe even a scanned sketch, if necessary? Do you want the contour lines >>> to be stepped, like the rectilinear boundaries of the pcolormesh >>> cells--that is, composed entirely of horizontal and vertical line segments? >> >> Yes, Eric, that's exactly what I want. Since my case was simple enough, >> I did it completely manually, with loads of calls to `plot` (I'm sure >> there would've been a simpler solution ... -- which one?). I attached >> the plot so you get an idea of what I want to do. > > Andreas, > > I have never seen a contour algorithm with an option to do that, but I > understand the motivation. I don't think it would be easy to implement; > contouring algorithms generally are not. > > You might get an adequate approximation by using nearest-neighbor > interpolation to interpolate your data to a very fine grid, and then > contour that. Eric, thanks, that's a good hint. I took a look into the C source of the contour algorithm and decided not to bother right now. But your suggestion should do it. Cheers, Andreas. -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Offset details for contour plot
I'm considering using Matplotlib to programmatically generate images for a web-based application. I want some specific information about contour plot images produced by Matplotlib and I was wondering if it was easy/possible to get this information. Imagine a contour plot rendered to a .png. For simplicity, assume the size is 1000x1000 pixels. Of course, this image has white-space, axes, axis labels, perhaps a colorbar, etc. The actual contour part, showing the data, is smaller than 1000x1000 pixels. I'd like to know: * the size (in pixels) of the actual contour part of the generated .png * the offset (in pixels) from the bottom left hand corner of the actual contour part Of course if pixel information isn't possible, offset and size as a percentage of the total image size would be fine. Thanks, -Dan --- Dan Karipides [EMAIL PROTECTED] - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Selectable contour(f) divisions
In using the contour as in: contour(X,Y,Z,N) N is a number of automatically chosen levels. I would like to contour based on data divisions. For instance, perhaps I'd like to use a contour or color-fill (contourf) every 2 units. I'm not seeing how to accomplish this. Any points in the right direction would be appreciated. Thanks! Bruce --- Bruce W. Ford Clear Science, Inc. br...@clearscienceinc.com http://www.ClearScienceInc.com 8241 Parkridge Circle N. Jacksonville, FL 32211 Skype: bruce.w.ford Google Talk: for...@gmail.com -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour coordinates
Hello, I am trying to extract the coordinates of contour lines. I tried the following: cs = *contour*(Z) for lev, col in zip(cs.levels, cs.collections): s = col._segments that I found in a previous post (title "contouring", by Jose Gómez-Dans-2<http://www.nabble.com/user/UserProfile.jtp?user=30071> Nov 30, 2007; 07:47am ) . I hoped that s will be a list of numpy arrays, each containing the (x,y) vertices defining a contour line at level lev. However, I got an error message: AttributeError: 'LineCollection' object has no attribute '_segments' How is it possible to get coordinates of the contours, similar to the MATLAB command [C,H] = *CONTOUR*(...) where the result in C is the coordinates of the contours. A similar question appeared in a post "contour data" (by Albert Swart<http://www.nabble.com/user/UserProfile.jtp?user=382945> May 17, 2006; 09:42am) but I could not understand the answer. Is it possible to get more specific directions with a simple example ? Thanks Eli -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Omitting curves from a legend
Ok. Thanks. I'll give the setp on the ContourSet thing a try. Documentation issue/question: I figured there was probably some way to set attributes individually using the return value from contour since contour's docstring helpfully tells me that countour returns a ContourSet object. However, 'ContourSet?' in ipython gives me nothing. Similarly with plot(), it says it returns a 'list of lines' but that is not so useful since I can't look up the docstring for 'list of lines'. --bb On 4/17/07, Eric Firing <[EMAIL PROTECTED]> wrote: > Maybe I should make _nolegend_ the default for contour and contourf > collections? > > Eric > > John Hunter wrote: > > On 4/13/07, Bill Baxter <[EMAIL PROTECTED]> wrote: > >> There are a couple things about legend that I'm finding a little > >> irksome. Is there some better way to do this? > >> > >> 1) if you have a contour, legend() wants to add all the contours to > >> the list. calling contour(...,label='_nolegend_') doesn't seem to > >> help. > > > > You should be able to set the "_nolegend_" label property on the > > contour set line collections like so: > > > > >>> cs = contour(...blah...) > > > > >>> for coll in cs.collections: > > coll.set_label('_nolegend_') > > > > of use "setp" for the same purpose. > > > > >>> setp(cs.collections, label='_nolegend_') > > > > contour doesn't use the kwargs to set the line collection properties, > > which is why it is not working in the contour commands. some plot > > commands use the kwargs to update the artist properties that the plot > > command creates, some do not, and the only way to know is the read the > > individual docstrings of the commands. > > > > Let me know if this works because it is untested. > - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contourf question
Thanks Eric. However, when I specify the same number of levels as suggested, contourf divides this example into three regions, with a diagonal 'stripe' instead of a clean boundary, so I guess I'm asking whether it's possible to trick contourf into generating a single boundary between the two regions such that it matches that found by contour? For the moment, a suitable workaround seems to be to do contourf(a,1,colors=('w','k')) where the background colour is white. This generates what I'm after. I notice also that linewidths is mentioned in the docstring under Obsolete:, but it seems to do nothing, so it should probably be removed from the docstring. thanks again, Gary Eric Firing <[EMAIL PROTECTED]> wrote: > Gary Ruben wrote: > > I'm notice that contourf behaves differently to contour by default in > > where it decides to position contours. For example, using pylab, if you try > > > > a=tri(10) > > contourf(a,0) > > contour(a,1) > > > > I'd have expected the contours to line up, but they don't. Is there a > > way to get contourf to place its contours at the same position as contour? > > Specify the same number of levels: > > contourf(a,1) > contour(a,1) > > > That takes care of this simple case. There are other cases, however, > where contour and contourf simply don't agree; contouring is ambiguous, > and only part of the algorithm is shared between contour and contourf. > For well-behaved datasets this is normally not a problem, but it becomes > obvious if you contour a random array. > > Eric - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plot order
Ok, I've spent a while searching through the mailing list archives and I can't find an answer for this relatively simple problem. I've plotted a series of contourf and contour plots on the same axes. First I plot a contourf. Next a contour on top of it. Then I want a contourf plotted on top of both the previous contourf and contour plots. And finally, a contour on top of the second contourf. However, when I do this the result is the two contour plots are drawn on top of the contourf plots no matter what. How do I hide the contours under a contourf? Jordan - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contourf question
[EMAIL PROTECTED] wrote: > Thanks Eric. > > However, when I specify the same number of levels as suggested, contourf > divides this example into three regions, with a diagonal 'stripe' instead of > a clean boundary, so I guess I'm asking whether it's possible to trick > contourf into generating a single boundary between the two regions such that > it matches that found by contour? > Now I see the problem; this is something of a corner case, but it may be pointing to a bug. Where do you really want the line to fall? Do you need to specify the number of contours instead of specifying the actual levels (boundaries)? Are you actually dealing with zeros and ones as in the example? If so, you probably want contour(a, [0.5]) contourf(a, [-1, 0.5, 2], colors=('w', 'k'), extend='neither') or contourf(a, [0.5, 2], colors=('k',), extend='neither') In this case you are saying "color everything between 0.5 and 2, and nothing else". Specifying one contour instead of giving the levels is yielding 0.6; this is a consequence of using the MaxNLocator by default to auto-select the levels. > For the moment, a suitable workaround seems to be to do > > contourf(a,1,colors=('w','k')) > > where the background colour is white. This generates what I'm after. > > I notice also that linewidths is mentioned in the docstring under Obsolete:, > but it seems to do nothing, so it should probably be removed from the > docstring. I will fix the docstring. Thanks. Eric > > thanks again, > Gary > > Eric Firing <[EMAIL PROTECTED]> wrote: >> Gary Ruben wrote: >>> I'm notice that contourf behaves differently to contour by default in >>> where it decides to position contours. For example, using pylab, if you try >>> >>> a=tri(10) >>> contourf(a,0) >>> contour(a,1) >>> >>> I'd have expected the contours to line up, but they don't. Is there a >>> way to get contourf to place its contours at the same position as contour? >> Specify the same number of levels: >> >> contourf(a,1) >> contour(a,1) >> >> >> That takes care of this simple case. There are other cases, however, >> where contour and contourf simply don't agree; contouring is ambiguous, >> and only part of the algorithm is shared between contour and contourf. >> For well-behaved datasets this is normally not a problem, but it becomes >> obvious if you contour a random array. >> >> Eric > - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Omitting curves from a legend
On 4/13/07, Bill Baxter <[EMAIL PROTECTED]> wrote: > There are a couple things about legend that I'm finding a little > irksome. Is there some better way to do this? > > 1) if you have a contour, legend() wants to add all the contours to > the list. calling contour(...,label='_nolegend_') doesn't seem to > help. You should be able to set the "_nolegend_" label property on the contour set line collections like so: >>> cs = contour(...blah...) >>> for coll in cs.collections: coll.set_label('_nolegend_') of use "setp" for the same purpose. >>> setp(cs.collections, label='_nolegend_') contour doesn't use the kwargs to set the line collection properties, which is why it is not working in the contour commands. some plot commands use the kwargs to update the artist properties that the plot command creates, some do not, and the only way to know is the read the individual docstrings of the commands. Let me know if this works because it is untested. JDH - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour question
Hello, I'm using a svn version of matplotlib and the API changed for contour. I want to have the coordinate of the contour. Before Eric Firing (I think) gave a solution to do it: val = contour(xRange,yRange,delchi2,[1]) t = asarray(val.collections[0].get_verts()) but now get_verts doesn't exist anymore. I tried to do: cs = contour(a) path = cs.collections[0].get_paths() but I don't know how to use it. Basically I think that I have the contour coordinate but I don't know how to recuperate them. I need it to export them in a data file so it's the reason I want to recuperate them. Thank you for any help N. ps: It's a little bit difficult to access to the help for a method now some, perhaps most, of them are missing a docstring. So it's difficult to understand what it is the meaning of each of them. example: col.get_paths? Type: instancemethod Base Class: String Form:> Namespace: Interactive File: /usr/lib/python2.5/site-packages/matplotlib/collections.py Definition: col.get_paths(self) Docstring: - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Contour of Number of Occurences in a Scatter Plot
Does anyone know how to do a contour plot of a set of X,Y data where each contour level has the same number of data points inside it? What I want to show is where most of the data is appearing in the x, y position for a scatter plot of ~1,000 points, so you can't just plot all those as points. This is similar to the probability density function for a scatter plot. In concept, you would start at the median of x and median of y and then include points by their distance from the median until you reach the number in each contour and draw a contour around this region. Then you would proceed outward from the contour to find more points. An alternative, but not exactly correct approach I have already done is to bin the data like a 2D histogram and then use the number of occurrences in each bin as the z value for contourf. I see this plot a lot in the scientific literature, so I know it must be possible, but haven't been able to find it on the web for python. Thanks, Mike -- View this message in context: http://www.nabble.com/Contour-of-Number-of-Occurences-in-a-Scatter-Plot-tp25083681p25083681.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plotting a contour from dicrete data points
hello ppl, hey i hav 3 .dat files... one has 1 column of x coords, another has 1 column of the same number of y coords and the last .dat file has the same number of corresponding values of a property[temperature] at those points in 1 column i was wondering how i cud make a contour of this data with the last .dat file being the z-values... i hav written the following code( saf2.py)[mind u ppl am a newbie @ python+matplotlib]... from pylab import * x = load('xcord2.dat') y = load('ycord2.dat') X, Y = meshgrid(x, y) Z = load('output1im.dat') contour(X,Y,Z) show() the following errors crop up: Traceback (most recent call last): File "F:\Python25\saf2.py", line 9, in contour(X,Y,Z) File "F:\Python25\Lib\site-packages\matplotlib\pylab.py", line 1776, in contour ret = gca().contour(*args, **kwargs) File "F:\Python25\Lib\site-packages\matplotlib\axes.py", line 4674, in contour return ContourSet(self, *args, **kwargs) File "F:\Python25\Lib\site-packages\matplotlib\contour.py", line 429, in __init__ x, y, z = self._contour_args(*args)# also sets self.levels, File "F:\Python25\Lib\site-packages\matplotlib\contour.py", line 601, in _contour_args x,y,z = self._check_xyz(args[:3]) File "F:\Python25\Lib\site-packages\matplotlib\contour.py", line 577, in _check_xyz raise TypeError("Input z must be a 2D array.") TypeError: Input z must be a 2D array. wat errors am i making? - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Combining pcolormesh and contour
>> On Tuesday, February 28, 2012, Andreas H. wrote: >> >>> Good morning, >>> >>> I'm creating the attached plot using pcolormesh(). What I would like to >>> do now is draw contour lines at +/- 2.5%, which follow the grid edges. >>> >>> The problem is that when I use contour(), the lines drawn do not follow >>> the grid edges but seem to be interpolated somehow. >>> >>> Do you have an idea how to draw the contour lines following the grid >>> edges? >>> >>> Your insight is very much appreciated :) >>> >>> Cheers, >>> Andreas. >>> >> >> This is because of a subtle difference in how pcolor-like functions and >> contour-like functions work. I always forget which is which, but one >> assumes that the z value lies on the vertices of the grid while the >> other >> assumes that it lies in the middle of each grid point. This is why you >> see >> them slightly offset from each other. > > Thanks, Ben! > > To `pcolormesh`, I pass the *edges* of the grid: > > xbin = linspace(0, 12, nxbin + 1) > ybin = np.linspace(-90, 90, nybin + 1) > > pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None', > vmin=-5, vmax=20) > > `contour`, however, wants the coordinates themselves. So I do > > spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T, > [-2.5, 2.5]) > > Still, the outcome is, well, unexpected to me. Actually, no matter if > contour wants centres or edges, the actual behaviour seems strange. There > is some interpolation going on, apparently. The input `pdata` has shape > (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid > movement in the x-direction. > > Any ideas? Okay, after some diving into matplotlib sources, I guess the interpolation comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So there seems to be no way to accomplish what I actually want with the current matplotlib API. Correct? If I wanted to do something about this, I would need to * implement a class `GriddedContourSet`, derived from `ContourSet`, where I implement the `_get_allsegs_and_allkinds` method appropriately. * add an additional keyword argument to `contour()` to make this gridded contourset an option when calling `contour()`. Is this all correct? If yes, I might start working on this if I get the time ... Cheers, Andreas. -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Pyplot contour plot - clabel padding
I have trouble with matplotlib / pyplot / basemap. I plot contour lines (air pressure) on a map. I use clabel to show the value of the contour lines. But the problem: the padding between the value and the contour line is too much. I have found the parameter "inline_spacing", which i have set to zero. But there is still to much free space. Any ideas? <http://matplotlib.1069221.n5.nabble.com/file/n44554/mslp.png> My code is as follows: Thanks a lot. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Pyplot-contour-plot-clabel-padding-tp44554.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] selecting part of a contour to plot
To all: I'm making a plot with an image and a contour on it. I use only one level in the call to contour, but it results in two distinct contours, an inner closed one and an outer open one. I want to plot only the outer piece. How might I go about that? I've been looking at the properties of the ContourSet object returned by the call to contour but can't find anything useful yet. Is there an attribute of ContourSet objects that contains the (x,y) values for the contour? Is there some way to see that a ContourSet object has separate pieces? Any help would be appreciated. Thanks, Jon -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problem with contour labels with logarithmic axis
Answering my own question... It's a question of order. I needed to set_yscale('log') before calling clabel. Jon > Hi all, > > I've run into a problem with a contour plot that has a > logarithmic > y-axis. The spacing around the inline contour label is too > large, > leading to a large segment of the contour being blocked > out/erased. I > tried making the plot with a linear axis and it didn't happen > in that > case, so I'm thinking that it has to do with the contour > labeling > routine not understanding logarithmic scaling. Attached is a > plot > demonstrating the problem. Is there a solution for this? > > Jon Slavin -- BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA Learn about the latest advances in developing for the BlackBerry® mobile platform with sessions, labs & more. See new tools and technologies. Register for BlackBerry® DevCon today! http://p.sf.net/sfu/rim-devcon-copy1 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Custom contour labels?
Hi, I am trying to make a contour plot using custom labels that consist only of text strings but can not figure it out. For example, if I do the following: A=arange(100) A=A.reshape(10,10) CS=contour(A,[50,]) clabel(CS) I get one contour line as expected, but instead of printing the contour level (50) I would like to print a simple string like "Some String." I tried using the fmt option of clabel, but it requires a way to stuff in the level value (ie. fmt="Some String %f"). Is it possible to use a simple string for these labels? Thanks, Scott. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Different contours in contour and contourf
Hi, running the simple test code: from pylab import * X, Y = meshgrid(linspace(-3,3,11),linspace(-3,3,11)) Z = randn(*X.shape) lev = linspace(Z.min(),Z.max(),11)[1:-1] contourf(X,Y,Z, lev, extend='both') contour(X,Y,Z, lev, colors='k') show() you will probably notice that the 'contourf' contours are not always exactly the sames as the 'contour' contours. Why is it so? Don't contour and contourf use the same contour constructor? Cheers. -- / \ ,, _._ _ |oo| _ / \__/ \ _ ((/ () \)) / \ Yannick COPIN (o:>* Doctus cum libro |/| ( )|oo| Institut de physique nucleaire de Lyon \/ _`\ /'_/ \(IN2P3 - France) / /.-' /\<>/\ `\.( () )_._ Tel: (33/0) 472 431 968 |` / \/ \ /`'--') http://snovae.in2p3.fr/ycopin/ \__,-'`| |. |\/ |/\/\|"\"` AIM: YcCopinICQ: 236931013 jgs | |. | \___/\___/ | |. | || - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour overlapping
Hi Bala, I'm not sure I understand, what you want, but maybe the following goes towards your direction # initialise two matrices with data matrix1 = ones((4,4)) matrix2 = 2*ones((4,4)) # and one empty matrix matrix3 = zeros((4, 4)) for i in xrange(len(matrix3[:, 0])): # all rows for j in xrange(len(matrix3[0, :])):# all columns if i > j: # if below diagonal take matrix1 matrix3[i, j] = matrix1[i, j] elif i < j: # if above diagonal take matrix 2 matrix3[i, j] = matrix2[i, j] In [40]: print matrix3 Out[40]: array([[ 0., 2., 2., 2.], [ 1., 0., 2., 2.], [ 1., 1., 0., 2.], [ 1., 1., 1., 0.]]) With that matrix3 holds elements of matrix2 in the upper part and elements of matrix1 below the diagonal. This one could be plotted with contour or contourf. Is that what you want? best regards Matthias On Wednesday 13 May 2009 18:12:53 Bala subramanian wrote: > Armin, > I tried this but what happens is it is not overlapping, actually when i > call contour function for the second time with matrix2, the plot is updated > with contour of matrix 2. > > contour(matrix1) > contour(matrix2). > > What i finally get is the contour of matrix 2 as the final plot. What i am > trying to do is that, i shd have one plot, with upper left panel for > matrix1 and lower right panel for matrix2 with their separation along the > diagonal. I have attached an example picture like which i am trying to > make. > > Bala > > On Wed, May 13, 2009 at 5:33 PM, Armin Moser > > wrote: > > Bala subramanian schrieb: > > > hai Armin, > > > > > > I looked through the examples. I could not find any example of > > > > overlapping > > > > > two differnet countours on the same plot. > > > > I think the first example filled contours does exactly that. You want to > > show two contours over each other in the same plot. > > You just have to substitute the Z in cset_1 with matrix_1 and in cset_2 > > with matrix_2. Of course it will be helpful to use different colormaps. > > E.g. a grey one for the underlying contour and a colored for the top one. > > > > x = arange(5) > > y = arange(5) > > x,y = meshgrid(x,y) > > Z = x**2+y**2 > > #contourf(Z,cmap=cm.binary) # filled contours gray > > contour(Z) # not filled contours colored > > error = rand(x.shape[0],x.shape[1]) # to generate a new Z > > Z = (x+error)**2+(y+error)**2 > > contour(Z) # colored not filled contours > > > > Armin -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contourf question
Thanks again Eric, Your examples are exactly what I was after. My colleague was hypothesizing that there's probably a less-than instead of a less-than-or-equal somewhere, if it is a bug. regards, Gary Eric Firing <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Thanks Eric. > > > > However, when I specify the same number of levels as suggested, contourf > > divides this example into three regions, with a diagonal 'stripe' instead > > of a clean boundary, so I guess I'm asking whether it's possible to trick > > contourf into generating a single boundary between the two regions such > > that it matches that found by contour? > > > Now I see the problem; this is something of a corner case, but it may be > pointing to a bug. > > Where do you really want the line to fall? > > Do you need to specify the number of contours instead of specifying the > actual levels (boundaries)? Are you actually dealing with zeros and > ones as in the example? If so, you probably want > > contour(a, [0.5]) > contourf(a, [-1, 0.5, 2], colors=('w', 'k'), extend='neither') > > or > > contourf(a, [0.5, 2], colors=('k',), extend='neither') > In this case you are saying "color everything between 0.5 and 2, and > nothing else". > > Specifying one contour instead of giving the levels is yielding 0.6; > this is a consequence of using the MaxNLocator by default to auto-select > the levels. > > > For the moment, a suitable workaround seems to be to do > > > > contourf(a,1,colors=('w','k')) > > > > where the background colour is white. This generates what I'm after. > > > > I notice also that linewidths is mentioned in the docstring under > > Obsolete:, but it seems to do nothing, so it should probably be removed > > from the docstring. > > I will fix the docstring. Thanks. > > Eric > > > > thanks again, > > Gary > > > > Eric Firing <[EMAIL PROTECTED]> wrote: > >> Gary Ruben wrote: > >>> I'm notice that contourf behaves differently to contour by default in > >>> where it decides to position contours. For example, using pylab, if you > >>> try > >>> > >>> a=tri(10) > >>> contourf(a,0) > >>> contour(a,1) > >>> > >>> I'd have expected the contours to line up, but they don't. Is there a > >>> way to get contourf to place its contours at the same position as contour? > >> Specify the same number of levels: > >> > >> contourf(a,1) > >> contour(a,1) > >> > >> > >> That takes care of this simple case. There are other cases, however, > >> where contour and contourf simply don't agree; contouring is ambiguous, > >> and only part of the algorithm is shared between contour and contourf. > >> For well-behaved datasets this is normally not a problem, but it becomes > >> obvious if you contour a random array. > >> > >> Eric > > > - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Combining pcolormesh and contour
On 02/28/2012 06:28 AM, Andreas H. wrote: >>> On Tuesday, February 28, 2012, Andreas H. wrote: >>> >>>> Good morning, >>>> >>>> I'm creating the attached plot using pcolormesh(). What I would like to >>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges. >>>> >>>> The problem is that when I use contour(), the lines drawn do not follow >>>> the grid edges but seem to be interpolated somehow. >>>> >>>> Do you have an idea how to draw the contour lines following the grid >>>> edges? >>>> >>>> Your insight is very much appreciated :) >>>> >>>> Cheers, >>>> Andreas. >>>> >>> >>> This is because of a subtle difference in how pcolor-like functions and >>> contour-like functions work. I always forget which is which, but one >>> assumes that the z value lies on the vertices of the grid while the >>> other >>> assumes that it lies in the middle of each grid point. This is why you >>> see >>> them slightly offset from each other. >> >> Thanks, Ben! >> >> To `pcolormesh`, I pass the *edges* of the grid: >> >> xbin = linspace(0, 12, nxbin + 1) >> ybin = np.linspace(-90, 90, nybin + 1) >> >> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None', >> vmin=-5, vmax=20) >> >> `contour`, however, wants the coordinates themselves. So I do >> >> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T, >> [-2.5, 2.5]) >> >> Still, the outcome is, well, unexpected to me. Actually, no matter if >> contour wants centres or edges, the actual behaviour seems strange. There >> is some interpolation going on, apparently. The input `pdata` has shape >> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid >> movement in the x-direction. >> >> Any ideas? > > Okay, after some diving into matplotlib sources, I guess the interpolation > comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So > there seems to be no way to accomplish what I actually want with the > current matplotlib API. Correct? > > If I wanted to do something about this, I would need to > > * implement a class `GriddedContourSet`, derived from `ContourSet`, where > I implement the `_get_allsegs_and_allkinds` method appropriately. > * add an additional keyword argument to `contour()` to make this gridded > contourset an option when calling `contour()`. > > Is this all correct? If yes, I might start working on this if I get the > time ... It is not at all clear to me what you want to do, as compared to what contour does. Can you illustrate with an extremely simple example? Maybe even a scanned sketch, if necessary? Do you want the contour lines to be stepped, like the rectilinear boundaries of the pcolormesh cells--that is, composed entirely of horizontal and vertical line segments? Eric > > Cheers, > Andreas. > > > > > -- > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Combining pcolormesh and contour
Am 28.02.2012 18:56, schrieb Eric Firing: > On 02/28/2012 06:28 AM, Andreas H. wrote: >>>> On Tuesday, February 28, 2012, Andreas H. wrote: >>>> >>>>> Good morning, >>>>> >>>>> I'm creating the attached plot using pcolormesh(). What I would like to >>>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges. >>>>> >>>>> The problem is that when I use contour(), the lines drawn do not follow >>>>> the grid edges but seem to be interpolated somehow. >>>>> >>>>> Do you have an idea how to draw the contour lines following the grid >>>>> edges? >>>>> >>>>> Your insight is very much appreciated :) >>>>> >>>>> Cheers, >>>>> Andreas. >>>>> >>>> >>>> This is because of a subtle difference in how pcolor-like functions and >>>> contour-like functions work. I always forget which is which, but one >>>> assumes that the z value lies on the vertices of the grid while the >>>> other >>>> assumes that it lies in the middle of each grid point. This is why you >>>> see >>>> them slightly offset from each other. >>> >>> Thanks, Ben! >>> >>> To `pcolormesh`, I pass the *edges* of the grid: >>> >>> xbin = linspace(0, 12, nxbin + 1) >>> ybin = np.linspace(-90, 90, nybin + 1) >>> >>> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, edgecolors='None', >>> vmin=-5, vmax=20) >>> >>> `contour`, however, wants the coordinates themselves. So I do >>> >>> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T, >>> [-2.5, 2.5]) >>> >>> Still, the outcome is, well, unexpected to me. Actually, no matter if >>> contour wants centres or edges, the actual behaviour seems strange. There >>> is some interpolation going on, apparently. The input `pdata` has shape >>> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid >>> movement in the x-direction. >>> >>> Any ideas? >> >> Okay, after some diving into matplotlib sources, I guess the interpolation >> comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So >> there seems to be no way to accomplish what I actually want with the >> current matplotlib API. Correct? >> >> If I wanted to do something about this, I would need to >> >> * implement a class `GriddedContourSet`, derived from `ContourSet`, where >> I implement the `_get_allsegs_and_allkinds` method appropriately. >> * add an additional keyword argument to `contour()` to make this gridded >> contourset an option when calling `contour()`. >> >> Is this all correct? If yes, I might start working on this if I get the >> time ... > > It is not at all clear to me what you want to do, as compared to what > contour does. Can you illustrate with an extremely simple example? > Maybe even a scanned sketch, if necessary? Do you want the contour lines > to be stepped, like the rectilinear boundaries of the pcolormesh > cells--that is, composed entirely of horizontal and vertical line segments? Yes, Eric, that's exactly what I want. Since my case was simple enough, I did it completely manually, with loads of calls to `plot` (I'm sure there would've been a simpler solution ... -- which one?). I attached the plot so you get an idea of what I want to do. Thanks for your help! Andreas. example.pdf Description: Adobe PDF document -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Combining pcolormesh and contour
On 02/28/2012 08:08 AM, Andreas H. wrote: > Am 28.02.2012 18:56, schrieb Eric Firing: >> On 02/28/2012 06:28 AM, Andreas H. wrote: >>>>> On Tuesday, February 28, 2012, Andreas H. wrote: >>>>> >>>>>> Good morning, >>>>>> >>>>>> I'm creating the attached plot using pcolormesh(). What I would like to >>>>>> do now is draw contour lines at +/- 2.5%, which follow the grid edges. >>>>>> >>>>>> The problem is that when I use contour(), the lines drawn do not follow >>>>>> the grid edges but seem to be interpolated somehow. >>>>>> >>>>>> Do you have an idea how to draw the contour lines following the grid >>>>>> edges? >>>>>> >>>>>> Your insight is very much appreciated :) >>>>>> >>>>>> Cheers, >>>>>> Andreas. >>>>>> >>>>> >>>>> This is because of a subtle difference in how pcolor-like functions and >>>>> contour-like functions work. I always forget which is which, but one >>>>> assumes that the z value lies on the vertices of the grid while the >>>>> other >>>>> assumes that it lies in the middle of each grid point. This is why you >>>>> see >>>>> them slightly offset from each other. >>>> >>>> Thanks, Ben! >>>> >>>> To `pcolormesh`, I pass the *edges* of the grid: >>>> >>>> xbin = linspace(0, 12, nxbin + 1) >>>> ybin = np.linspace(-90, 90, nybin + 1) >>>> >>>> pl = spl.pcolormesh(xbin, ybin, pdata.T, cmap=cmap, >>>> edgecolors='None', >>>> vmin=-5, vmax=20) >>>> >>>> `contour`, however, wants the coordinates themselves. So I do >>>> >>>> spl.contour((xbin[:-1]+xbin[1:])/2., (ybin[:-1]+ybin[1:])/2, pdata.T, >>>> [-2.5, 2.5]) >>>> >>>> Still, the outcome is, well, unexpected to me. Actually, no matter if >>>> contour wants centres or edges, the actual behaviour seems strange. There >>>> is some interpolation going on, apparently. The input `pdata` has shape >>>> (12, 72) (or 72,12), and I definitely wouldn't expect this sub-grid >>>> movement in the x-direction. >>>> >>>> Any ideas? >>> >>> Okay, after some diving into matplotlib sources, I guess the interpolation >>> comes within the function `QuadContourSet._get_allsegs_and_allkinds`. So >>> there seems to be no way to accomplish what I actually want with the >>> current matplotlib API. Correct? >>> >>> If I wanted to do something about this, I would need to >>> >>> * implement a class `GriddedContourSet`, derived from `ContourSet`, where >>> I implement the `_get_allsegs_and_allkinds` method appropriately. >>> * add an additional keyword argument to `contour()` to make this gridded >>> contourset an option when calling `contour()`. >>> >>> Is this all correct? If yes, I might start working on this if I get the >>> time ... >> >> It is not at all clear to me what you want to do, as compared to what >> contour does. Can you illustrate with an extremely simple example? >> Maybe even a scanned sketch, if necessary? Do you want the contour lines >> to be stepped, like the rectilinear boundaries of the pcolormesh >> cells--that is, composed entirely of horizontal and vertical line segments? > > Yes, Eric, that's exactly what I want. Since my case was simple enough, > I did it completely manually, with loads of calls to `plot` (I'm sure > there would've been a simpler solution ... -- which one?). I attached > the plot so you get an idea of what I want to do. Andreas, I have never seen a contour algorithm with an option to do that, but I understand the motivation. I don't think it would be easy to implement; contouring algorithms generally are not. You might get an adequate approximation by using nearest-neighbor interpolation to interpolate your data to a very fine grid, and then contour that. Eric > > Thanks for your help! > Andreas. > > > > -- > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > > > > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour and contourf order
So I've got a plot with a contour and a contourf on it. The contour always appears on top of the contourf, no matter what order I issue the commands in; I want to use the contourf to block out part of the contour. ContourSets don't appear to have a zorder. How do I do this? Jordan - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] colormap extractions
Hey, I'm using matplot lib to make surface and contour plots of different functions based on the set of data. (so I have a surface plot thats basically f1(x,y) and a contour thats f2(x,y)) I want to color the surface plot with the exact colors that are shown in the contour plot. (The surface is a structure shape and the contour plot is the stress along the shape, I want to plot the surface of the shape with the colors representing the stress) I'm not sure how I can paste the colors from the contour plot onto the surface. If anyone has anything that can help I'd really appreciate it, thanks! -- View this message in context: http://old.nabble.com/colormap-extractions-tp31365189p31365189.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Contour, numbering contourlones
George LeCompte <[EMAIL PROTECTED]> writes: >The contours labels show 3 zeros beyond the decimal point. Is it >possible to force these labels to integers? If so how? If not why >not? clabel(CS, inline=1, fontsize=10, fmt='%3.0f') >Is there a way to browse previous postings to matplotlib-users > without looking month by month? For example can I bring up all > postings regarding 'contour'? This was discussed recently: http://thread.gmane.org/gmane.comp.python.matplotlib.general/9915/focus=9917 You can search the list on at least sourceforge.net, gmane.org, and mail-archive.com: http://sourceforge.net/search/?ml_name=matplotlib-users&type_of_search=mlists&group_id=80706&words=contour http://search.gmane.org/?query=contour&group=gmane.comp.python.matplotlib.general http://www.mail-archive.com/search?q=contour&l=matplotlib-users%40lists.sourceforge.net -- Jouni K. Seppänen http://www.iki.fi/jks - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour lines not hidden by patches
Can't figure this out: I create a figure, add some axes, define data to be plotted as a contourf + contour on top and then add some patches to hide some regions of my plot. The patches hide the contourf correctly, as expected, but not the contour lines... Could someone telle me whether I'm doing something wrong ? Below are the code lines. I'm using python 2.4, matplotlib 0.91.2 Thanks in advance, Aure #-- pylab.clf() fig = pylab.figure(figsize=(7.,3.8),dpi=100,facecolor='white') axes1 = fig.add_axes((.),label='axes1') axes2 = fig.add_axes((.),label='axes2') axes3 = fig.add_axes((.....),label='axes3') #define contour data contourstep = 0.05 contourx = np.arange(0.01,2.5+contourstep,contourstep) contoury = np.arange(0.01,4.+contourstep,contourstep) contourxy1 = np.ones((len(contoury),len(contourx))) contourxy2 = np.ones((len(contoury),len(contourx))) x = np.arange(0.,6.,0.01) for j in range(contourxy1.shape[0]): for k in range(contourxy1.shape[1]): newval1=... newval2=... contourxy1[j,k] = newval1 contourxy2[j,k] = newval2 #add contour levels = np.arange(0.0,0.85,0.05) cf1 = axes1.contourf(-contourx,contoury,contourxy2,levels,cmap=bone_r,extend = 'max') #cmap=mpl.cm.gray_r) cf2 = axes2.contourf(contourx,contoury,contourxy1,levels,cmap=bone_r,extend = 'max') #cmap=mpl.cm.gray_r) levels2 = np.arange(0.,.45,0.05) axes1.contour(-contourx,contoury,contourxy2,levels2,colors='gray') axes2.contour(contourx,contoury,contourxy1,levels2,colors='gray') #add patches axes1.add_patch(mpl.patches.Polygon([(-1.,1),(-2.,1.),(-2.,2.)], edgecolor='k', facecolor='w', )) axes1.add_patch(mpl.patches.Polygon([(-1.,1.),(0.,0.),(0.,1.)], edgecolor='k', facecolor='w', )) axes2.add_patch(mpl.patches.Polygon([(0.,1.),(2.,1.),(2.,2.),(0.,2.)], edgecolor='k', facecolor='w', )) pylab.savefig(outputfilename) #-- -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Masked nan
I have a problem that arose when I tried to run the gridding irregularly spaced data demo on the wiki http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data When I run the attached script, which sets one value of an array to nan, masks the array where there are nan, and tries to plot it using contour(), I get the following errors: /usr/lib/python2.4/site-packages/numpy/core/ma.py:604: UserWarning: Cannot automatically convert masked array to numeric because data is masked in one or more locations. warnings.warn("Cannot automatically convert masked array to "\ Traceback (most recent call last): File "masked_nan.py", line 18, in ? contour(x, y, z) File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 1754, in contour ret = gca().contour(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 4092, in contour return ContourSet(self, *args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 429, in __init__ x, y, z = self._contour_args(*args)# also sets self.levels, File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 614, in _contour_args lev = self._autolev(z, 7) File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line 517, in _autolev zmargin = (zmax - zmin) * 0.001 # so z < (zmax + zmargin) TypeError: unsupported operand type(s) for -: 'str' and 'str' I am using >>> numpy.__version__ '1.0' >>> matplotlib.__version__ '0.87.7' Is there a way to use contour() and plot arrays whose elements may be nan? Thanks, Paul import matplotlib import numpy import numpy.core.ma as ma from pylab import * a = linspace(0, 1, 3) b = linspace(0, 1, 3) x, y = meshgrid(a, b) z = x + y z[0][0] = numpy.nan z = ma.masked_where(numpy.isnan(z), z) contour(x, y, z) show()- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Contour/Contourf misunderstanding?
Hi All, I am trying to create a contour map with matplotlib. I have modified the source code for the contour sample which comes with the matplotlib 0.98.3 online documentation: I am using the "contour(X, Y, Z, V)" API call and, as the docs say: """ contour(X,Y,Z,V) draw contour lines at the values specified in sequence V """ I have specified a 20-elements vector in V, buit I still only see 6 contours being drawn, namely the ones at the values: [-1.0, -0.5, 0.0, 0.5, 1.0, 1.5] I attach my small sample to the message. Am I doing something worng in my call to contour? Why I am unable to see the 20 contour I specified in my vector V? Another related problem is with contourf: if I modify the attached sample to use contourf and clabel, I get this error: Traceback (most recent call last): File "E:\MyProjects\prova143.py", line 24, in plt.clabel(CS, fontsize=9, inline=1) File "C:\Python25\lib\site-packages\matplotlib\pyplot.py", line 1736, in clabel ret = gca().clabel(*args, **kwargs) File "C:\Python25\lib\site-packages\matplotlib\axes.py", line 6027, in clabel return CS.clabel(*args, **kwargs) File "C:\Python25\lib\site-packages\matplotlib\contour.py", line 161, in clabel self.labelCValueList = np.take(self.cvalues, self.labelIndiceList) File "C:\Python25\lib\site-packages\numpy\core\fromnumeric.py", line 85, in take return take(indices, axis, out, mode) IndexError: index out of range for array This is in Windows XP, Python 2.5.2, matplotlib 0.98.3, numpy 1.2.0. Thank you for your suggestions. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ # CODE START #!/usr/bin/env python import matplotlib import numpy as np import matplotlib.mlab as mlab import matplotlib.pyplot as plt delta = 0.025 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) X, Y = np.meshgrid(x, y) Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1) # difference of Gaussians Z = 10.0 * (Z2 - Z1) V = np.linspace(np.min(np.min(Z)), np.max(np.max(Z)), 20) print V # And you can manually specify the colors of the contour plt.figure() CS = plt.contourf(X, Y, Z, V=V) plt.clabel(CS, fontsize=9, inline=1) plt.show() # CODE END -- SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Contour: label cumulative value
Hi, Is it possible to label cumulative value in a contour? I'm currently plotting a probability distribution by using gaussian_kde[1], but what I really care is the 0.68 percentage contour. So instead of label the local value on a contour, is it possible to label a cumulative value? Thanks! Hong [1]: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.gaussian_kde.html#scipy.stats.gaussian_kde -- "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to remove a contour plot?
On Sat, Nov 5, 2011 at 3:52 PM, krastanov.ste...@gmail.com < krastanov.ste...@gmail.com> wrote: > I suppose it is possible to delete all collections one by one, but that's > an ugly solution. And as I'm not aware of the behind the scenes work done > by contour it's a bit dangerous. > > Is there a standard way to remove a contour plot? > > Regards > Stefan Krastanov > > This one bit me recently, too. You just have to loop through the contour object's collections member and remove each one. Ben Root -- RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problem with colorbar of contour
Hello, I have a contour with a clim smaller than the limits of my data... and because of this there is an error when I try to add a colorbar. Can someone help? Thanks MMA eg: x=arange(20) y=arange(30) x,y=meshgrid(x,y) v=sqrt(x+y) # max=6.928, min=0.0 # next is ok figure() contour(x,y,v) clim(0,7) colorbar() # next gives the error: "ValueError: levels are outside colorbar range" figure() contour(x,y,v) clim(2,6) colorbar() - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Update a contour plot
Hi Ralph, I don't think there exists a function like the line-'set_data'-method for collections, which are generated by 'contour'. This particular method of lines only changes the data but leave anything else unchanged. I attached an easy approach of updating a contour plot (simply deleting old collections), but I'm not sure that this is the best solution. Kind regards, Matthias On Monday 28 September 2009 13:52:42 Ralph Kube wrote: > Hi, > is there a way to update a contour plot? I need to display a series of > contour plots from a directory with data files and want to view them > consecutively, preferrably without building a gui for it. Is there an > easy way out? > > Cheers, Ralph update_contour_plot.py Description: application/python -- Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] problems with labeling contour lines - 2nd try
Hello - I have two problems labeling contour lines in 0.98.3. First, when I call clabel, it removes all contours that are not labeled (because the label doesn't fit on the section of contour, I presume). This seems like a bug to me (or a really odd feature). Easy example: >>> x,y = meshgrid( linspace(-10,10,50), linspace(-10,10,50) ) >>> z = log(x**2 + y**2) >>> cobj = contour(x,y,z) >>> cobj.clabel() >>> draw() Second, when using the new manual labeling of contour labels works (which is pretty neat!), how do I end this feature? The doc string says: right click, or potentially click both mouse buttons together (which already worries me). Neither works for me on win32, mpl 0.98.3, TkAgg backend, interactive mode. Does anybody have a solution? Thanks, Mark - 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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Updating a colorbar
On 06/27/2012 09:12 PM, Mads Ipsen wrote: > Hi, > > Suppose you do this: > > axes = self.figure().get_axes() > contour = axes.contourf(x,y,z) > colorbar = self.figure().colorbar(contour) > > Suppose that the contour data changes, can you update the colorbar with > the new data? > > Currently I remove the colorbar and insert a new one - but I have a > feeling that something smarter could be done. When you say "the contour data changes", I assume you mean you are contouring a new set of data, with new contour levels, and not just changing the cmap. In this case there is no point in trying to save something from the old colorbar, so remaking it is the right thing to do. Simple, effective, foolproof. (If only the cmap is changed, then the existing colorbar should be getting updated automatically.) Eric > > Best regards, > > Mads > -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] jagged edges on masked contour plots
Hi all I have an application requiring that I do contour plots for masked data. At the edge of my contour plots, I'm getting fragmented contours due to missing points on the corner of a cell in my grid. Is there any way that the contour drawing code can be set up so that it plots contours even if a cell in the grid only has data on two sides? I suspect that the rule for contour plots is that no contours are shown if *any* of the point on the four corners are missing. There is an example with the jagged edge shown in the attached image. Cheers JP -- John Pye School of Mechanical and Manufacturing Engineering The University of New South Wales Sydney NSW 2052 Australia t +61 2 9385 5127 f +61 2 9663 1222 mailto:john.pye_AT_student_DOT_unsw.edu.au http://pye.dyndns.org/ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour plots with logarithmic axes
Jae-Joon Lee wrote: > Contour will work as expected if the axes is in log scale. See below. > > z = np.arange(100).reshape((10,10)) > x = np.logspace(0, 4, 10) > y = np.logspace(0, 4, 10) > > ax1 = subplot(121) > ax1.contour(np.log10(x), np.log10(y), z) > > ax2 = subplot(122) > ax2.set_xscale("log") > ax2.set_yscale("log") > ax2.contour(x, y, z) JJ, Actually, I think your example illustrates that there is a problem with the second approach--the first subplot generates straight lines, the second does not. The contour calculation itself really needs to be done in coordinates that are linear as displayed, because the contour locations are determined by linear interpolation. Adding support for log scales to make contour work right in your second example would be easy; making it work with more general transforms, and making it work when the transform changes after the call to contour, would be harder. I will have to look into this. Eric > > Regards, > > -JJ > > p.s. good to see another astronomer begin to use matplotlib. > > > On Mon, Jan 11, 2010 at 3:33 PM, Jonathan Slavin > wrote: >> Is there any way to simply make a contour plot with logarithmic axes >> using matplotlib? I found a workaround by plotting log10(x), log10(y), >> but it'd be nicer if it was more direct. >> >> As someone new to matplotlib (experienced in IDL) I'm finding much to >> like, but some things are more difficult for no clear reason. It would >> seem to me that whether the axes are logarithmic or not would be a nice >> thing to have as an attribute of the plot object. I'm not familiar yet >> with the matplotlib internals to know how difficult that would be to >> implement, but it sure would be convenient. >> >> Jon Slavin >> >> >> -- >> This SF.Net email is sponsored by the Verizon Developer Community >> Take advantage of Verizon's best-in-class app development support >> A streamlined, 14 day to market process makes app distribution fast and easy >> Join now and get one step closer to millions of Verizon customers >> http://p.sf.net/sfu/verizon-dev2dev >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > -- > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Unwanted lines between contourf() contour levels
Hello, In my filled contour plot: http://imgur.com/vXoCL.png There are faint lines between the contour levels. I think they are yellow since they disappear in the yellow parts of the graph and are most obvious in the red areas. Is there any way to get rid of these lines? The number of contour levels is arbitrary, and I don't need them emphasized with a moire pattern. Thank you, -Ryan -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Combining pcolormesh and contour
Good morning, I'm creating the attached plot using pcolormesh(). What I would like to do now is draw contour lines at +/- 2.5%, which follow the grid edges. The problem is that when I use contour(), the lines drawn do not follow the grid edges but seem to be interpolated somehow. Do you have an idea how to draw the contour lines following the grid edges? Your insight is very much appreciated :) Cheers, Andreas. <>-- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] update an existing contour plot with new data
Thanks a lot, this solutions seems to serve my purpose. A new method C.remove() would of course be even better. One could say the problem is solved, but why does there no method exist to update a contour plot as there is for many other plot routines, i.e. set_xdata/set_ydata for plot set_data for imshow or set_UVC for quiver and so on. set_array should be the corresponding method for contour plots, and if type C.get_array() I actually get the data array that I used to plot the countours! My purpose of this is to animate the contour plot, and I did read somewhere that updating the plot is much faster/more efficient than deleting and recreating the plot. - Original Message - From: "Ryan May" To: "Johannes Röhrs" Cc: matplotlib-users@lists.sourceforge.net Sent: Friday, 9 July, 2010 5:11:37 PM Subject: Re: [Matplotlib-users] update an existing contour plot with new data On Fri, Jul 9, 2010 at 6:28 AM, Johannes Röhrs wrote: > I have some troubles updating a contour plot. I reduced my code to a simple > example to reproduce the problem: > > [code] > from pylab * > import scipy as sp > > x=sp.arange(0,2*sp.pi,0.1) > X,Y=sp.meshgrid(x,x) > f1=sp.sin(X)+sp.sin(Y) > f2=sp.cos(X)+sp.cos(Y) > > figure() > C=contourf(f1) > show() > > C.set_array(f2) > draw() > [\code] > > What do I need to do to update an existing contour plot with new data? The set_array() method (I think) only impacts the colormapping information for contourf, and even then doesn't appear to update. What you need to do is make a new contour plot and remove the old one, especially if you need to change the underlying contoured data. This should be as easy as C.remove(), but for some reason, this doesn't exist (I'll go add it in a minute). So instead, you need to do the following: import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 2 * np.pi, 0.1) X,Y = np.meshgrid(x,x) f1 = np.sin(X) + np.sin(Y) f2 = np.cos(X) + np.cos(Y) plt.figure() C = plt.contourf(f1) plt.show() for coll in C.collections: plt.gca().collections.remove(coll) C = plt.contourf(f2) plt.draw() Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Assign labels to colorbar extensions (user or development issue)
I am not sure if this is a user issue or a development issue. Using version 1.4.2 My code allows the user to hone in on a specific contour range, by changing the minimum and maximum of the contour and the number of levels. I am using colorbar "extend" to prevent any white patches, as the data may have values outside the contour range. I want the extensions to have tick values but I can't seem to figure out, how to do it? This is my code import numpy as np import matplotlib.pyplot as plt xi = np.array([0., 0.5, 1.0])#xi data yi = np.array([0., 0.5, 1.0])#yi data zi = np.array([[0., 1.0, 2.0],[0., 1.0, 2.0],[-0.1, 1.0, 2.0]])#zi data n=5#number of levels of user specified range umin=0.5#user defined minimum of contour umax=1#user defined maximum of contout u = np.linspace(umin, umax, n)#user specified contour levels cbtics = np.hstack([zi.min(),u,zi.max()])#contour ticks including maximum and minimum of zi plt.contourf(xi, yi, zi, u, cmap=plt.cm.jet,extend='both')#plot contour cbar=plt.colorbar(extendrect='True',extendfrac='auto',spacing='proportional')#plot colorbar print cbar.ax.get_ylim()#show y limits print cbar.ax.get_yticks()#show yticks plt.show() Using the user entered values: ylim are (-0.25, 1.25) but the yticks are: [ 0. 0.2 0.4 0.6 0.8 1. ] range from 0 to 1 I'm guessing that the difference between ylim (-0.25 to 1.25) and yticks (0 to 1) is that I am using extensions, so is there no way to update y ticks to include the extensions so that I can assign labels to the extensions? -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Assign-labels-to-colorbar-extensions-user-or-development-issue-tp44392.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Contour Plotting of Varied Data on a Shape
Christopher Barker wrote: > > Erik Schweller wrote: >> My overall goal is to generate contour plots for a wide range of input >> data. The data points are not regularly spaced and do not align to >> any grid. The data points represent measurements taken from a model >> that can take on a variety of shapes. To make matters more difficult, >> I'd prefer not to interpolate around corners of the model. > > It strikes me that when you are working with unstructured data like > this, it may be better to keep it unstrucured -- do the delanauy > triangulation and directly contour from that. It's actually prety easy > to contour a triangular mesh. > > Unfortunately, I haven't see code to do it in scipy or MPL. Am I wrong? > Is there something there. If not, there really should be it seems a bit > silly to shoehorn your data to a rectangular grid just to contour it. > > I suppose NN interpolation is essentially doing this already, but it > introduces issues with a boundary that doesnt' line up to a rectangular > grid. > > As I think about it, I'm going to have to write code to do this (contour > an unstructured triangular mesh) sometime soon, so please let me know if > it does exist already -- if not I'll try to remember to contribute it > when I get around to it. > > -Chris > Chris, I found this old thread. Did you ever find code to directly interpolate a triangulation? I need to do the same thing. Thanks, Geoff -- Geoffrey Ely g...@usc.edu http://earth.usc.edu/~gely/ Department of Earth Sciences University of Southern California Los Angeles, CA 90089-0740 -- View this message in context: http://old.nabble.com/Contour-Plotting-of-Varied-Data-on-a-Shape-tp25089018p27826931.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour plot confined by shapefile border
Hello, I would like to ask for some hints and help. I am currently trying to plot a "pseudo contour" over a Basemap. This contour is confined by borders obtained from a shapefile. I can generate the contour, I can retrieve the shapefile and put them on a basemap. What I have not been able to do is to limit the contour plot such that it only fills the area defined by a shapefile (in my case it is bordered by Province Lampung). You can use different shapefile for example, as the point of my question is how to limit contour fill by a shapefile. Shapefile can be downloaded from http://www.gadm.org/data/shp/IDN_adm.zip The generated figure can be found here: https://lh3.googleusercontent.com/-hMlwe6MAjdc/Tf6HlxYxn1I/AEY/exdzSv30ZL4/s640/to_matplotlib_userlists.png Thanks for the help! -- Lukmanul Hakim Here's the code: from pylab import cm import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.basemap import Basemap #Define area about Province Lampung ulat, llat, ulon, llon = -2.5, -6.5, 107, 103 m = Basemap(projection='merc', lon_0=0.0, llcrnrlon=llon, llcrnrlat=llat, urcrnrlon=ulon, urcrnrlat=ulat, resolution='i') #Read shapefile of Province Lampung s = m.readshapefile('E:/Works/UNILA/Research/IDN_adm/LampungMap/LampungMap', 'lampung') #Define area for contour plot llon1,ulon1 = 103,106 llat1,ulat1 = -6,-3.5 #Generate random data nx,ny=5,5 data2 = np.random.sample((ny,nx)) x = np.linspace(llon1, ulon1, nx) y = np.linspace(llat1, ulat1, ny) X,Y = np.meshgrid(x,y) px,py = m(X,Y) m.contourf(px, py, data2, cmap=cm.jet) m.drawcoastlines()#(linewidth=0.5) m.drawparallels(np.arange(-6.5,-2.5,1.),labels=[1,0,0,0],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) # draw parallels m.drawmeridians(np.arange(102.,108.,1.),labels=[0,0,0,1],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) # draw meridians plt.show() -- EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Unwanted lines between contourf() contour levels
Geoffrey Ely wrote: > On Nov 12, 2009, at 10:03 AM, Eric Firing wrote: >> Geoffrey Ely wrote: >>> Ryan, >>> I have noticed the same issue with contourf. It seems to be a thin >>> gap between neighboring polygons showing through. You can turn on >>> a thin contour line of the same color to cover the gap: >>> for c in pylab.contourf( x, y, z ).collections: >>> c.set_linewidth( 0.1 ) >>> Not ideal, but it works. >> This is a good workaround so long as you leave alpha=1 and don't >> mind the very slight position shifts caused by stroking the line. > > Yes, the position shift I don't like. Would be better if there was a > way to set the zorder of the line lower than the polygon. Maybe a > better workaround is to just do a line contour() before the contourf()? Unfortunately, that won't work in general, because the code path for contour differs from that for contourf such that the patch boundaries don't always coincide with the corresponding contour lines. Generating filled contours is more complicated than generating line contours. Eric > > contour( x, y, z ) > contourf( x, y, z ) > > -Geoff > > -- > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Combining pcolormesh and contour
On Tue, Feb 28, 2012 at 9:10 AM, Benjamin Root wrote: > On Tuesday, February 28, 2012, Andreas H. wrote: >> >> Good morning, >> >> I'm creating the attached plot using pcolormesh(). What I would like to >> do now is draw contour lines at +/- 2.5%, which follow the grid edges. >> >> The problem is that when I use contour(), the lines drawn do not follow >> the grid edges but seem to be interpolated somehow. >> >> Do you have an idea how to draw the contour lines following the grid >> edges? >> >> Your insight is very much appreciated :) >> >> Cheers, >> Andreas. > > > This is because of a subtle difference in how pcolor-like functions and > contour-like functions work. I always forget which is which, but one > assumes that the z value lies on the vertices of the grid while the other > assumes that it lies in the middle of each grid point. This is why you see > them slightly offset from each other. By definitition, with pcolormesh you're giving it the edges of the grid cells. In fact, for an NxN grid of data, you should have N+1xN+1 grids of x,y values. Contour is given the actual grid and values. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour plot without smoothing
Hey guys, I think I found the answer to my question: No, it is not possible to have a contour along the grid of a pcolor plot out of the box, because the contour would take the shortest path between neighbouring same-value-points in a dataset. Pcolor merely changes the representation of these data. What I would probably need is using the pcolor plot as an underlying dataset for a contour plot. If that works I don't know. To give some background: The data in the attached pdf are not be interpolated because this would give the fake impression of a continuous parameter space. This is why I don't want any diagonal lines cutting through the little boxes in the pcolor plot. So, if there was a workaround, I would be happy if somebody could point me to it! Cheers, Sebastian S3b4st1an wrote: > > Hello everyone, > > I've got a contour plot on a pcolor plot: > > http://old.nabble.com/file/p31038837/m3921-csv-RMSfinalSlip-pleft.pdf > m3921-csv-RMSfinalSlip-pleft.pdf > > I would like to have the contours (the 2 black lines) go along the grid > without any diagonal lines. Is that possible? And if so, could somebody > please tell me, how? > > Cheers, Sebastian > -- View this message in context: http://old.nabble.com/contour-plot-without-smoothing-tp31038837p31046299.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] clabel font
Dear all, I am making a contour plot using matplotlib. The title and axis annotations require math symbols so I set usetex=True in the rc('text',usetex). However that made ALL texts in LaTeX (incl. contour labels) and the contour labels look not satisfying when rendered by TeX. What I needed is LaTeX for all texts EXCEPT the contour labels (I'd like to use the default sans-serif font for them.) Can you tell me some hints? Thanks in advance. Cong. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Combining pcolormesh and contour
On Tuesday, February 28, 2012, Andreas H. wrote: > Good morning, > > I'm creating the attached plot using pcolormesh(). What I would like to > do now is draw contour lines at +/- 2.5%, which follow the grid edges. > > The problem is that when I use contour(), the lines drawn do not follow > the grid edges but seem to be interpolated somehow. > > Do you have an idea how to draw the contour lines following the grid edges? > > Your insight is very much appreciated :) > > Cheers, > Andreas. > This is because of a subtle difference in how pcolor-like functions and contour-like functions work. I always forget which is which, but one assumes that the z value lies on the vertices of the grid while the other assumes that it lies in the middle of each grid point. This is why you see them slightly offset from each other. I hope that clarifies everything for you. Ben Root -- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Contour/Contourf misunderstanding?
Andrea Gavana wrote: > Hi Mauro & All, > > On Wed, Dec 10, 2008 at 10:32 AM, Mauro Cavalcanti wrote: >> Dear Andrea, >> >> Greetings. I have tried your script here. >> >> 2008/12/10 Andrea Gavana <[EMAIL PROTECTED]>: >>> I attach my small sample to the message. Am I doing something worng in >>> my call to contour? Why I am unable to see the 20 contour I specified >>> in my vector V? >> But you can. Simply change the line below to: >>> CS = plt.contourf(X, Y, Z, V=V) >>> CS = plt.contourf(X, Y, Z, V) >> (I did not understand the reason behind the "V=V" in the argument list?) > > Ah! I thought "V" was a keyword argument. Shame on me. Thank you for the hint. > >>> Another related problem is with contourf: if I modify the attached >>> sample to use contourf and clabel, I get this error: >> Well, this one I do not understand myself. > > Uhm, I will wait for further suggestions. Maybe I am doing something > stupid, again ;-) Not stupid at all; it just happens that clabel works only with contour, not with contourf. Clabel operates on the LineCollection generated by contour, but contourf generates a PolyCollection. It should be possible to call contourf, then contour, then clabel, and then make the LineCollection from contour invisible, but I don't have time now to come up with an example. Eric > > Thank you! > > Andrea. > > "Imagination Is The Only Weapon In The War Against Reality." > http://xoomer.alice.it/infinity77/ > > -- > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. > The future of the web can't happen without you. Join us at MIX09 to help > pave the way to the Next Web now. Learn more and register at > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Legend for contour plots
Francesco Montesano, on 2011-01-21 15:44, wrote: > Dear All, > > I am using contour plot and I am drawing different contours with > different colors and linestyles and I would like to have a legend with > a caption for each contour function used. > Here you can see an example of what I would like to do > > >> #create the 2D histogram and the x and y axis > >> x, y = np.random.normal(0, 0.5, 1000), np.random.normal(0, 1, 1000) > >> h, xe,ye = np.histogram2d(x,y, bins=25) > >> xe, ye = (xe[1:]+xe[:-1])/2, (ye[1:]+ye[:-1])/2 > >> > >> lines,text = [], [] # initialise lists > >> > >> #contour plots > >> lines.append(plt.contour(xe,ye,h, levels=[10,9], linestyles="-", > >> colors="k")) > >> text.append("level=10, 9") > >> > >> lines.append(plt.contour(xe,ye,h, levels=[5,4], linestyles="--", > >> colors="r")) > >> text.append("level=5, 4") > >> > >> plt.legend(lines, text) > > Everything goes well untill I plot the legend. At the end of the mail > I report the error that I get. > Anyway, if I do > >> plt.legend(lines) > I don't get any errors but it's quite useless, since the text of the > legend is just like: > > as you can see from the attached figure. > > > I've the feeling that the problem is that "contour" gives back a > "matplotlib.contour.ContourSet instance", while the functions like > "plot" gives back a " > Does anyone knows how to do what I want? > Hi Francesco, here's one way of getting what you want, instead of calling legend on your 'lines' variable as you had it, do this: actual_lines = [cs.collections[0] for cs in lines] plt.legend(actual_lines, text) As you note, the call to plt.countour does not return lines, it returns contour sets (which is why I called the variable 'cs' in my example). Poking around in ipython, I saw that each contour set has a collections attribute which holds the actual lines. hope that helps, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 signature.asc Description: Digital signature -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug in labeling contour lines
A little follow-up. When I use keyword argument inline=False, it doesn't remove the lines without a label. So it seems that when using inline=True the unlabeled contours get a white box, but no label (because it doesn't fit) which essentially removes the entire contour. Mark On Wed, Aug 6, 2008 at 2:27 PM, Mark Bakker <[EMAIL PROTECTED]> wrote: > Hello list - > > There seems to be a bug in labeling contour lines. > When I call clabel, it removes all contours that are not labeled (because > the label doesn't fit on the section of contour, I presume). > This seems like a bug to me (or a really odd feature). > > Easy example: > > >>> x,y = meshgrid( linspace(-10,10,50), linspace(-10,10,50) ) > >>> z = log(x**2 + y**2) > >>> cobj = contour(x,y,z) > >>> cobj.clabel() > > >>> draw() > > And now all contours without a label are gone. On my machine it draws > labels on contours from 1 through 5, and erases the contours in the middle > of the plot with values -2, -1, and 0. > > Mark > > - 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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour overlapping
Thank you Matthias, Sebastin and Armin!!! My matrices are square matrices and not rectangular one. I tried the way of creating a new matrix from existing ones as suggested by matthias and it worked great. I will try the masked array method too. Thank you all once again, Bala On Wed, May 13, 2009 at 6:45 PM, Matthias Michler wrote: > Hi Bala, > > I'm not sure I understand, what you want, but maybe the following goes > towards > your direction > > # initialise two matrices with data > matrix1 = ones((4,4)) > matrix2 = 2*ones((4,4)) > # and one empty matrix > matrix3 = zeros((4, 4)) > > for i in xrange(len(matrix3[:, 0])): # all rows >for j in xrange(len(matrix3[0, :])):# all columns >if i > j: # if below diagonal take matrix1 >matrix3[i, j] = matrix1[i, j] >elif i < j: # if above diagonal take matrix 2 >matrix3[i, j] = matrix2[i, j] > > In [40]: print matrix3 > Out[40]: > array([[ 0., 2., 2., 2.], > [ 1., 0., 2., 2.], > [ 1., 1., 0., 2.], > [ 1., 1., 1., 0.]]) > > With that matrix3 holds elements of matrix2 in the upper part and elements > of > matrix1 below the diagonal. This one could be plotted with contour or > contourf. > > Is that what you want? > > best regards Matthias > > On Wednesday 13 May 2009 18:12:53 Bala subramanian wrote: > > Armin, > > I tried this but what happens is it is not overlapping, actually when i > > call contour function for the second time with matrix2, the plot is > updated > > with contour of matrix 2. > > > > contour(matrix1) > > contour(matrix2). > > > > What i finally get is the contour of matrix 2 as the final plot. What i > am > > trying to do is that, i shd have one plot, with upper left panel for > > matrix1 and lower right panel for matrix2 with their separation along the > > diagonal. I have attached an example picture like which i am trying to > > make. > > > > Bala > > > > On Wed, May 13, 2009 at 5:33 PM, Armin Moser > > > > wrote: > > > Bala subramanian schrieb: > > > > hai Armin, > > > > > > > > I looked through the examples. I could not find any example of > > > > > > overlapping > > > > > > > two differnet countours on the same plot. > > > > > > I think the first example filled contours does exactly that. You want > to > > > show two contours over each other in the same plot. > > > You just have to substitute the Z in cset_1 with matrix_1 and in cset_2 > > > with matrix_2. Of course it will be helpful to use different colormaps. > > > E.g. a grey one for the underlying contour and a colored for the top > one. > > > > > > x = arange(5) > > > y = arange(5) > > > x,y = meshgrid(x,y) > > > Z = x**2+y**2 > > > #contourf(Z,cmap=cm.binary) # filled contours gray > > > contour(Z) # not filled contours colored > > > error = rand(x.shape[0],x.shape[1]) # to generate a new Z > > > Z = (x+error)**2+(y+error)**2 > > > contour(Z) # colored not filled contours > > > > > > Armin > > > > > -- > The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your > production scanning environment may not be a perfect world - but thanks to > Kodak, there's a perfect scanner to get the job done! With the NEW KODAK > i700 > Series Scanner you'll get full speed at 300 dpi even with all image > processing features enabled. http://p.sf.net/sfu/kodak-com > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to remove a contour plot?
I suppose it is possible to delete all collections one by one, but that's an ugly solution. And as I'm not aware of the behind the scenes work done by contour it's a bit dangerous. Is there a standard way to remove a contour plot? Regards Stefan Krastanov -- RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour or intensity plot.
yadin Bocuma Rivas <[EMAIL PROTECTED]> writes: > i want to generate a contour plot [...] an example will be very > helpfull Please see examples/contour_demo.py in the matplotlib distribution and http://matplotlib.sourceforge.net/matplotlib.pylab.html#-contour -- Jouni K. Seppänen http://www.iki.fi/jks - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Contour Plotting of Varied Data on a Shape
Erik Schweller wrote: > My overall goal is to generate contour plots for a wide range of input > data. The data points are not regularly spaced and do not align to > any grid. The data points represent measurements taken from a model > that can take on a variety of shapes. To make matters more difficult, > I'd prefer not to interpolate around corners of the model. It strikes me that when you are working with unstructured data like this, it may be better to keep it unstrucured -- do the delanauy triangulation and directly contour from that. It's actually prety easy to contour a triangular mesh. Unfortunately, I haven't see code to do it in scipy or MPL. Am I wrong? Is there something there. If not, there really should be it seems a bit silly to shoehorn your data to a rectangular grid just to contour it. I suppose NN interpolation is essentially doing this already, but it introduces issues with a boundary that doesnt' line up to a rectangular grid. As I think about it, I'm going to have to write code to do this (contour an unstructured triangular mesh) sometime soon, so please let me know if it does exist already -- if not I'll try to remember to contribute it when I get around to it. -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 chris.bar...@noaa.gov -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour coordinates
Eli Brosh wrote: > Hello, > I am trying to extract the coordinates of contour lines. > I tried the following: > > cs = *contour*(Z) > for lev, col in zip(cs.levels, cs.collections): > s = col._segments > > that I found in a previous post (title "contouring", by Jose > Gómez-Dans-2 <http://www.nabble.com/user/UserProfile.jtp?user=30071> > Nov 30, 2007; 07:47am ) . > > I hoped that s will be a list of numpy arrays, each containing the > (x,y) vertices > defining a contour line at level lev. > However, I got an error message: > AttributeError: 'LineCollection' object has no attribute '_segments' > > > How is it possible to get coordinates of the contours, similar to the > MATLAB command > [C,H] = *CONTOUR*(...) > where the result in C is the coordinates of the contours. > > A similar question appeared in a post "contour data" (by Albert Swart > <http://www.nabble.com/user/UserProfile.jtp?user=382945> May 17, 2006; > 09:42am) but I could not understand the answer. > Is it possible to get more specific directions with a simple example ? > > > Thanks > Eli Eli: Calling get_paths() on each line collection in CS.collections will return a list of Path objects. From the Path objects, you can get a Nx2 array of vertices from the "vertices" attribute. There are no examples that I know of, but if you get it to do what you want to do, it would be great if you could contribute an example. As you noted, this question has come up several times before. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : jeffrey.s.whita...@noaa.gov 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] which interpolation type is used by contour() ?
On 06/13/2010 10:27 PM, David Kremer wrote: >> Hi Everyone, >> I'd like to know, what is the underline mechanism that connects the > points >> of my gridded data when I use >> contour(). >> Can I control this mechanism ? No. If you want smoother contours you can either use a 2-D interpolation method to map your data to a finer grid and then use that for contouring, or you can use a spline algorithm to smooth the contour paths directly. There are more problems and pitfalls with the second method than with the first, so don't bother trying it. >> Maybe I missed it in the documentation, but it's not clear to me. >> Thanks in advance, >> > I think it's the same than this used in the imshow method. Would you > like to check ? No, image display and contouring use completely different algorithms. Imshow uses any of several 2-D interpolation methods to map values given on one square grid onto another square grid. It does not create paths; it simply displays pixels. In contouring, linear interpolation is used to find the intersections between contour level lines and grid lines; the intersection points are connected by line segments; and the line segments are assembled into complete contour paths, which are then drawn (contour) or filled (contourf). Eric > > greetings. > > -- > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Masked nan
Paul Novak wrote: > I have a problem that arose when I tried to run the gridding irregularly > spaced data demo on the wiki > http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data > > When I run the attached script, which sets one value of an array to > nan, masks the array where there are nan, and tries to plot it using > contour(), I get the following errors: > > /usr/lib/python2.4/site-packages/numpy/core/ma.py:604: UserWarning: > Cannot automatically convert masked array to numeric because data > is masked in one or more locations. > warnings.warn("Cannot automatically convert masked array to "\ > Traceback (most recent call last): > File "masked_nan.py", line 18, in ? > contour(x, y, z) > File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line > 1754, in contour > ret = gca().contour(*args, **kwargs) > File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line > 4092, in contour > return ContourSet(self, *args, **kwargs) > File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line > 429, in __init__ > x, y, z = self._contour_args(*args)# also sets self.levels, > File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line > 614, in _contour_args > lev = self._autolev(z, 7) > File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line > 517, in _autolev > zmargin = (zmax - zmin) * 0.001 # so z < (zmax + zmargin) > TypeError: unsupported operand type(s) for -: 'str' and 'str' > > I am using > >>> numpy.__version__ > '1.0' > >>> matplotlib.__version__ > '0.87.7' > > Is there a way to use contour() and plot arrays whose elements may be > nan? > > Thanks, > Paul Paul: Your test script works for me (numpy 1.0, matplotlib 0.87.7, python2.5 on macos x). -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1FAX : (303)497-6449 325 BroadwayBoulder, CO, USA 80305-3328 - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug in labeling contour lines
Hello list - There seems to be a bug in labeling contour lines. When I call clabel, it removes all contours that are not labeled (because the label doesn't fit on the section of contour, I presume). This seems like a bug to me (or a really odd feature). Easy example: >>> x,y = meshgrid( linspace(-10,10,50), linspace(-10,10,50) ) >>> z = log(x**2 + y**2) >>> cobj = contour(x,y,z) >>> cobj.clabel() >>> draw() And now all contours without a label are gone. On my machine it draws labels on contours from 1 through 5, and erases the contours in the middle of the plot with values -2, -1, and 0. Mark - 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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] changing axes of contour plot
Hi, I have a contour plot with a log scale on the x and y axes and I would like it to read "10^1 10^2 10^3 10^4". How would I go about doing this? Here's how I'm currently making the plot.. contour( log10(x), log10(y), z ) This only displays something like "0 1 2 3 4". Any suggestions? If there is a really obvious solution to this, then I apologize, but I can't seem to figure it out. Thanks -- View this message in context: http://www.nabble.com/changing-axes-of-contour-plot-tp19444605p19444605.html Sent from the matplotlib - users mailing list archive at Nabble.com. - 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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] update an existing contour plot with new data
Hi, I have some troubles updating a contour plot. I reduced my code to a simple example to reproduce the problem: [code] from pylab * import scipy as sp x=sp.arange(0,2*sp.pi,0.1) X,Y=sp.meshgrid(x,x) f1=sp.sin(X)+sp.sin(Y) f2=sp.cos(X)+sp.cos(Y) figure() C=contourf(f1) show() C.set_array(f2) draw() [\code] The problem is that C.set_array(f2) does not show any effect, not even after I call draw(). Shouldn't the array f2 be displayed after that? In comparison, the following code using imshow instead of contour works well: [code] figure() I=imshow(f1) show() I.set_data(f2) draw() [\code] What do I need to do to update an existing contour plot with new data? Greetings Johannes -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour and contourf order
Jordan Dawe wrote: > So I've got a plot with a contour and a contourf on it. The contour > always appears on top of the contourf, no matter what order I issue the > commands in; I want to use the contourf to block out part of the > contour. ContourSets don't appear to have a zorder. How do I do this? Jordan, The ContourSet has a collections attribute which is a list of either LineCollection or PolyCollection objects. Each of these is an Artist, and all Artists have zorder, so you should be able to iterate over them and use their set_zorder methods to modify the zorder. Eric - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Omitting curves from a legend
Bill Baxter wrote: > There are a couple things about legend that I'm finding a little > irksome. Is there some better way to do this? > > 1) if you have a contour, legend() wants to add all the contours to > the list. calling contour(...,label='_nolegend_') doesn't seem to > help. I think it would be quite unusual that someone would want contour lines to show up in a legend, so I made the change I suggested in an earlier response to this thread: the LineCollections in the ContourSet now have their labels set to _nolegend_. If someone really does want contour lines in a legend, these labels still can be changed manually, as described earlier in this thread. Eric - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] updating an existing plot
Hi, I'm making contour plots of a field distribution, and overlaid on that is a grid that I create using hlines() and vlines(). I want to change the contour plot many times, but keep the grid the same. Right now, I have clear the axes with cla() then plot the new contour and replot the grid. This slows things down a lot, and I'm wondering if anyone knows of a way to update the contour plot without replotting the grid. thanks, trevis Trevis Crane Postdoctoral Research Assoc. Department of Physics University of Ilinois 1110 W. Green St. Urbana, IL 61801 p: 217-244-8652 f: 217-244-2278 e: [EMAIL PROTECTED] - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] clabel font
On Tuesday 14 August 2007 07:18:58 am [EMAIL PROTECTED] wrote: > Dear all, > > I am making a contour plot using matplotlib. The title and axis annotations > require math symbols so I set usetex=True in the rc('text',usetex). > However that made ALL texts in LaTeX (incl. contour labels) and > the contour labels look not satisfying when rendered by TeX. What I needed > is LaTeX for all texts EXCEPT the contour labels (I'd like to use the > default sans-serif font for them.) > > Can you tell me some hints? I dont think this is possible. usetex is kind of an all or nothing deal. Darren - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] labeling contours with roman numerals
Michael - This trick for replacing contour labels with a string was posted a little while back (by someone else):* * class FormatFaker(object): def __init__(self, str): self.str = str def __mod__(self, stuff): return self.str A=arange(100).reshape(10,10) CS=contour(A,[50,]) CS.clabel(fmt=FormatFaker('Some String')) > > From: Michael Hearne <[EMAIL PROTECTED]> > Subject: [Matplotlib-users] labeling contours with roman numerals > To: Matplotlib Users > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="us-ascii" > > Does a LineCollection generated by contour() have a property that > holds the labels? I would like to label my contour lines with roman > numerals, and cannot figure out how to get clabel to do that. > > Thanks, > > Mike > > > - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how can i make a contour plot with mask
> Shu: I'd make a mask by finding the points on the grid that are outside > your polygon. Then use that mask to create a masked array from your > data (masking the points you don't want to plot). matplotlib's contourf > knows how to deal with masked arrays (at least when the masked region > isn't too complicated). The basemap toolkit can plot data on map > projections with coastlines and political boundaries (as in the PyNGL > example you forwarded). > > -Jeff Thanks Jeff.Following your advice I have successed to get a masked contour plot.Matplotlib can do it good. in my case, x is array for axis X and y for axis Y z is data for contour mask is a mask array with the same dimensions as z. ma.array(z,mask=mask) contour(x,y,z) In my case,I used kriging interpolation to interpolate an array of irregulation station data into a rectangular grid first and then plot contour with matplotlib. I wanna know if matplotlib have such interpolation functions or geostatistics functions. Thanks again. shu - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Broken contour lines
Hi, when I use the function "contour" sometimes I get a broken contour line. This should be continuous. Probably this is a bug. Does anyone know anything about this issue? Regards, Ozgur -- FREE DOWNLOAD - uberSVN with Social Coding for Subversion. Subversion made easy with a complete admin console. Easy to use, easy to manage, easy to install, easy to extend. Get a Free download of the new open ALM Subversion platform now. http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Can mpl adjust scale while doing contour?
I wanna my contour to display at the certain pixels and only set figure size can't do this job. Is there any way to get the scale value while mpl doing contour, and more, to change it? Great thanks for your replies. - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour coordinates
On Tue, Jan 27, 2009 at 5:33 PM, Jeff Whitaker wrote: > Eli Brosh wrote: >> Hello, >> I am trying to extract the coordinates of contour lines. >> I tried the following: >> >> cs = *contour*(Z) >> for lev, col in zip(cs.levels, cs.collections): >> s = col._segments >> >> that I found in a previous post (title "contouring", by Jose >> Gómez-Dans-2 <http://www.nabble.com/user/UserProfile.jtp?user=30071> >> Nov 30, 2007; 07:47am ) . >> >> I hoped that s will be a list of numpy arrays, each containing the >> (x,y) vertices >> defining a contour line at level lev. >> However, I got an error message: >> AttributeError: 'LineCollection' object has no attribute '_segments' >> >> >> How is it possible to get coordinates of the contours, similar to the >> MATLAB command >> [C,H] = *CONTOUR*(...) >> where the result in C is the coordinates of the contours. >> >> A similar question appeared in a post "contour data" (by Albert Swart >> <http://www.nabble.com/user/UserProfile.jtp?user=382945> May 17, 2006; >> 09:42am) but I could not understand the answer. >> Is it possible to get more specific directions with a simple example ? >> >> >> Thanks >> Eli > Eli: Calling get_paths() on each line collection in CS.collections will > return a list of Path objects. From the Path objects, you can get a Nx2 > array of vertices from the "vertices" attribute. There are no examples > that I know of, but if you get it to do what you want to do, it would be > great if you could contribute an example. As you noted, this question > has come up several times before. > > -Jeff > > -- > Jeffrey S. Whitaker Phone : (303)497-6313 > Meteorologist FAX: (303)497-6449 > NOAA/OAR/PSD R/PSD1Email : jeffrey.s.whita...@noaa.gov > 325 BroadwayOffice : Skaggs Research Cntr 1D-113 > Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg > > > > -- > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > I'm not sure if this is entirely what you (Eli) are looking for, but I have code that will contour model data on a map and then extract the lat,lon pairs of all the vertices. If this is what you are looking for, I'm happy to share what I've done. -Patrick -- Patrick Marsh Graduate Research Assistant School of Meteorology University of Oklahoma http://www.patricktmarsh.com -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour plot confined by shapefile border
On Sunday, June 19, 2011, Lukmanul Hakim wrote: > Hello, > > I would like to ask for some hints > and help. I am currently trying to plot a "pseudo contour" over a Basemap. > This contour is confined by borders obtained from a shapefile. I can generate > the contour, I can retrieve the shapefile and put them on a basemap. What I > have not been able to do is to limit the contour plot such that it only fills > the area defined by a shapefile (in my case it is bordered by Province > Lampung). You can use different shapefile for example, as the point of my > question is how to limit contour fill by a shapefile. > > Shapefile can be downloaded from http://www.gadm.org/data/shp/IDN_adm.zip > > The generated figure can be found here: > https://lh3.googleusercontent.com/-hMlwe6MAjdc/Tf6HlxYxn1I/AEY/exdzSv30ZL4/s640/to_matplotlib_userlists.png > > Thanks for the help! > -- > Lukmanul Hakim > > Here's the code: > > from pylab import cm > import matplotlib.pyplot as plt > import numpy as np > from mpl_toolkits.basemap import Basemap > > #Define area about Province Lampung > ulat, llat, ulon, llon = -2.5, -6.5, 107, 103 > m = Basemap(projection='merc', lon_0=0.0, llcrnrlon=llon, > llcrnrlat=llat, urcrnrlon=ulon, urcrnrlat=ulat, > resolution='i') > > > #Read shapefile of Province Lampung > s = m.readshapefile('E:/Works/UNILA/Research/IDN_adm/LampungMap/LampungMap', > 'lampung') > > #Define area for contour plot > llon1,ulon1 = 103,106 > llat1,ulat1 = -6,-3.5 > > #Generate random data > nx,ny=5,5 > data2 = np.random.sample((ny,nx)) > x = np.linspace(llon1, ulon1, nx) > y = np.linspace(llat1, ulat1, ny) > X,Y = np.meshgrid(x,y) > px,py = m(X,Y) > m.contourf(px, py, data2, cmap=cm.jet) > m.drawcoastlines()#(linewidth=0.5) > m.drawparallels(np.arange(-6.5,-2.5,1.),labels=[1,0,0,0],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) > # draw parallels > m.drawmeridians(np.arange(102.,108.,1.),labels=[0,0,0,1],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) > # draw meridians > > plt.show() Not exactly sure how to do this, but if you can get a true/false mask of the region in the same shape as the input data, then you can have a masked array that goes into contourf. Any area where the mask was true will be blanked. The hard part, though is getting the mask. I hope that helps! Ben Root -- EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Different contours in contour and contourf
Yannick Copin wrote: > Hi, > > Eric Firing wrote: >>> from pylab import * >>> X, Y = meshgrid(linspace(-3,3,11),linspace(-3,3,11)) >>> Z = randn(*X.shape) >>> lev = linspace(Z.min(),Z.max(),11)[1:-1] >>> contourf(X,Y,Z, lev, extend='both') >>> contour(X,Y,Z, lev, colors='k') >>> show() >> >> Now, you may be wondering why we can't simply use the boundary of the >> filled regions for the lines as well, to guarantee they are the same. >> The reason is that filled contour boundaries include cuts connecting >> inner and outer contours, and also inner boundaries (edges of masked >> regions--except when affected by a bug) and the outer boundaries of >> the domain). It might be possible to simply exclude those line >> segments from the line contours, but it is not clear to me that the >> effort would be well-spent. > > OK, thanks for the explanations. I was using this dual approach > contourf+contour to emphasize the contours from contourf. So is there a > direct way to set the linewidth and linecolor (and linestyle?) of > contours from contourf? (I suspect not, according to contourf > documentation: > > contourf differs from the Matlab (TM) version in that it does not > draw the polygon edges, because the contouring engine yields > simply connected regions with branch cuts. To draw the edges, > add line contours with calls to contour. > > ) > You could turn on coloring of the edges, but I don't think you would like the result because the edges would include the boundary lines and the cut lines. The ContourSet object returned by contour and contourf has a .collections attribute. For contourf it is a list of PolyCollections, and you can set their attributes. >> I think that the differences illustrated in your example will occur >> almost entirely in pathologically ambiguous cases, but it is also > > Not necessarily pathological cases, just noisy data :-/ (I agree my > randn-based example was a bit extreme!) You might be able to avoid the problem most of the time by using some gridding routine, preferably something that uses a bit of curvature, to double the number of points in each dimension. I haven't tried it, but I suspect that this would turn even a very noisy field into something that would be contoured the same by contour and contourf. > > Cheers. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Structure of contour object returned from tricontourf
All, We try to generate contour polygons from an unstructured triangular grid stored in a netcdf file: import netCDF4 import matplotlib.tri as tri # read data var = netCDF4.Dataset('filename.cdf').variables x = var['x'][:] y = var['y'][:] elems = var['element'][:,:]-1 data = var['attrname'][:] # create triangulation triang = tri.Triangulation(x, y, triangles=elems) # generate contour polygons levels = numpy.linspace(0, maxlevel, num=numlevels) contour = plt.tricontourf(triang, data, levels=levels) # extract geometries for coll in contour.collections: # handle all geometries for one level for p in coll.get_paths(): polys = p.to_polygons() ... At this point we assume, that polys[0] is a linear ring to be interpreted as a polygon exterior and polys[1:] are the corresponding interiors for polys[0]. Here are our questions: Is this assumption correct? Is there any detailed documentation describing the structure of the returned geometries? Are the linear rings supposed to be correctly oriented (area > 0 for exteriors and area < 0 for the interiors)? Thanks! Regards Hartmut --- http://boost-spirit.com http://stellar.cct.lsu.edu -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Possible To Contour Around 1-Sigma Curves?
I have a function on a 2d grid that looks like a skewed mound. I would like to make a contour plot where each contour represents each sigma, or confidence interval. I.e. Is there a straight forward way to make such a contour plot where it is then easy to say: This line is 1-sigma or 68% confidence interval, this line is 95% confidence interval, etc... Such plots look like this: http://lambda.gsfc.nasa.gov/product/map/current/pub_papers/threeyear/parameters/images/Med/ds_f07_PPT_M.png where the first region of each graph is the on sigma or 68% confidence interval and the second line is the 95% confidence interval. Thanks. Joseph Smidt -- Joseph Smidt Physics and Astronomy 4129 Frederick Reines Hall Irvine, CA 92697-4575 Office: 949-824-3269 -- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contours on unstructured triangle meshes
Ian Curington wrote: > Does anyone have extensions or hints on how to create high quality > vector contour plots on unstructured triangle meshes, with values at > nodes? I can convert to structured with griddata, but I much prefer to > get a direct contour from the original triangles. Thanks! Ian: Matplotlib's contour cannot do this (although I believe the underlying c code does have this capability). I think it would be a useful addition. For right now, however, your workaround is the best solution. PyNGL (http://www.pyngl.ucar.edu/Graphics/contour_grids.shtml) can contour triangular meshes, if you'd like to give that a try. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1FAX : (303)497-6449 325 BroadwayBoulder, CO, USA 80305-3328 - 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 Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Custom contour labels?
"Zelakiewicz, Scott (GE, Research)" <[EMAIL PROTECTED]> writes: > I get one contour line as expected, but instead of printing the contour > level (50) I would like to print a simple string like "Some String." I > tried using the fmt option of clabel, but it requires a way to stuff in > the level value (ie. fmt="Some String %f"). Is it possible to use a > simple string for these labels? I don't know if there is a recommended way, but here is a quick hack: class FormatFaker(object): def __init__(self, str): self.str = str def __mod__(self, stuff): return self.str A=arange(100).reshape(10,10) CS=contour(A,[50,]) CS.clabel(fmt=FormatFaker('Some String')) show() -- Jouni K. Seppänen http://www.iki.fi/jks - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Region within contour --> 2D array
On 2014/08/28, 3:02 AM, Matthew Czesarski wrote: > Hi Matplotlib Users! > > > > I have some 2-d arrays, which i am displaying with implot, and deriving > contours for with contour. Easy - I'm just pulling them out of > collections[0].get_paths() . > > However what's not easy is that I would like to recover a 1-0 or > True-False array of the array values (pixels) that fall within the > contours. Some line crossing algorithm/floodfill could do it, but I > guess that matplotlib's fill() or contourf() must do this under the hood > anyway. I've looked into the output both functions, but I don't see > anything obvious.. > > Does anybody know if there's an a way to pull out a such an array from > matplotlib? Any pointers are appreciated! Make an array of (x, y) pairs from the X and Y you use in your call to contour, and then feed that array to the contains_points() method of your contour Path. This will give you the desired Boolean array for any given Path; depending on what you want, you might need to combine arrays for more than one Path. To get closed paths, I think you will want to use contourf, not contour. Eric > > Cheers, > Matt > > > -- > Slashdot TV. > Video for Nerds. Stuff that matters. > http://tv.slashdot.org/ > > > > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Saving as eps file shifts image?
No, I don't think the issue is a flip in the y-axis. I have a number of different examples of this, and many in which the contour is an ellipse so I can tell that the overall positioning is correct. It seems like something is going wrong only when I save the image... Thanks for the suggestion though! Jenna On Wed, Jul 21, 2010 at 3:40 PM, Jenna Lemonias wrote : > I am trying to save a matplotlib 2d array image with an overlaid contour as > an eps file. The contour appears to be shifted with respect to the image > underneath in the eps file, particularly when I zoom in on the image. This > shift is not noticeable in the plot within matplotlib. > > I am using imshow to display the image. The contour is created by plotting > a list of closely-spaced x,y coordinates. The attached file matplotlib.png > is a screenshot of the (zoomed-in) image as displayed by matplotlib. The > attached file epsfile.png is a screenshot of the (zoomed-in) eps file. When > I save this image as an eps file, it is actually 1 of 20 subplots and the > shift is noticeable in each subplot. > > Thanks in advance for your help! > > Jenna > > Just as a wild guess, could this actually be an issue with how imshow uses the upper-left corner for (0,0)? I have seen 1-pixel shifts before, but this shift is a little dramatic and I am left wondering if what we are really seeing is that the contour that is desired should actually be fliped in the y-axis? Maybe you could try another example where you try to draw a contour further away from the center of the image and see if it still goes in the spot you expect it to be? Ben Root -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Masked nan
On Thursday 21 December 2006 13:43, Jeff Whitaker wrote: > Paul Novak wrote: > > I have a problem that arose when I tried to run the gridding irregularly > > spaced data demo on the wiki > > http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data > > > > When I run the attached script, which sets one value of an array to > > nan, masks the array where there are nan, and tries to plot it using > > contour(), I get the following errors: > > > > /usr/lib/python2.4/site-packages/numpy/core/ma.py:604: UserWarning: > > Cannot automatically convert masked array to numeric because data > > is masked in one or more locations. > > warnings.warn("Cannot automatically convert masked array to "\ > > Traceback (most recent call last): > > File "masked_nan.py", line 18, in ? > > contour(x, y, z) > > File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line > > 1754, in contour > > ret = gca().contour(*args, **kwargs) > > File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line > > 4092, in contour > > return ContourSet(self, *args, **kwargs) > > File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line > > 429, in __init__ > > x, y, z = self._contour_args(*args)# also sets self.levels, > > File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line > > 614, in _contour_args > > lev = self._autolev(z, 7) > > File "/usr/lib/python2.4/site-packages/matplotlib/contour.py", line > > 517, in _autolev > > zmargin = (zmax - zmin) * 0.001 # so z < (zmax + zmargin) > > TypeError: unsupported operand type(s) for -: 'str' and 'str' > > > > I am using > > > > >>> numpy.__version__ > > > > '1.0' > > > > >>> matplotlib.__version__ > > > > '0.87.7' > > > > Is there a way to use contour() and plot arrays whose elements may be > > nan? > > > > Thanks, > > Paul > > Paul: Your test script works for me (numpy 1.0, matplotlib 0.87.7, > python2.5 on macos x). It worked fine for me too. Do you happen to have numerix : Numeric in your matplotlibrc file? Darren - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour question
.get_paths() returns a list of Path objects. (See path.py). For each Path object, you can get an Nx2 array of vertices from its "vertices" member. You can also use the "iter_segments" method to iterate through each of its vertices, but that's primarily only useful when there may be bezier curves in the path, which there won't be in the case of contours. Missing docstrings is definitely a problem that will need to be worked on. Cheers, Mike [EMAIL PROTECTED] wrote: > Hello, > > I'm using a svn version of matplotlib and the API changed for contour. I want > to have the coordinate of the contour. Before Eric Firing (I think) gave a > solution to do it: > > val = contour(xRange,yRange,delchi2,[1]) > t = asarray(val.collections[0].get_verts()) > > but now get_verts doesn't exist anymore. > > I tried to do: > > cs = contour(a) > path = cs.collections[0].get_paths() > > but I don't know how to use it. Basically I think that I have the contour > coordinate but I don't know how to recuperate them. I need it to export them > in a data file so it's the reason I want to recuperate them. > > Thank you for any help > > N. > > ps: It's a little bit difficult to access to the help for a method now some, > perhaps most, of them are missing a docstring. So it's difficult to > understand what it is the meaning of each of them. > > example: > > col.get_paths? > Type: instancemethod > Base Class: > String Form: > > Namespace: Interactive > File: /usr/lib/python2.5/site-packages/matplotlib/collections.py > Definition: col.get_paths(self) > Docstring: > > > > > > > - > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > 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 - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Legend for contour plots
Dear Paul, Thank you, it does exacly what I want to do. I searched a bit into the "contour" instance, but I was biased since I was looking for something like "get_line". cheers Francesco 2011/1/21 Paul Ivanov : > Francesco Montesano, on 2011-01-21 15:44, wrote: >> Dear All, >> >> I am using contour plot and I am drawing different contours with >> different colors and linestyles and I would like to have a legend with >> a caption for each contour function used. >> Here you can see an example of what I would like to do >> >> >> #create the 2D histogram and the x and y axis >> >> x, y = np.random.normal(0, 0.5, 1000), np.random.normal(0, 1, 1000) >> >> h, xe,ye = np.histogram2d(x,y, bins=25) >> >> xe, ye = (xe[1:]+xe[:-1])/2, (ye[1:]+ye[:-1])/2 >> >> >> >> lines,text = [], [] # initialise lists >> >> >> >> #contour plots >> >> lines.append(plt.contour(xe,ye,h, levels=[10,9], linestyles="-", >> >> colors="k")) >> >> text.append("level=10, 9") >> >> >> >> lines.append(plt.contour(xe,ye,h, levels=[5,4], linestyles="--", >> >> colors="r")) >> >> text.append("level=5, 4") >> >> >> >> plt.legend(lines, text) >> >> Everything goes well untill I plot the legend. At the end of the mail >> I report the error that I get. >> Anyway, if I do >> >> plt.legend(lines) >> I don't get any errors but it's quite useless, since the text of the >> legend is just like: >> >> as you can see from the attached figure. >> >> >> I've the feeling that the problem is that "contour" gives back a >> "matplotlib.contour.ContourSet instance", while the functions like >> "plot" gives back a "> >> Does anyone knows how to do what I want? >> > Hi Francesco, > > here's one way of getting what you want, instead of calling > legend on your 'lines' variable as you had it, do this: > > actual_lines = [cs.collections[0] for cs in lines] > plt.legend(actual_lines, text) > > As you note, the call to plt.countour does not return lines, it > returns contour sets (which is why I called the variable 'cs' in > my example). Poking around in ipython, I saw that each contour > set has a collections attribute which holds the actual lines. > > hope that helps, > -- > Paul Ivanov > 314 address only used for lists, off-list direct email at: > http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 > > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.10 (GNU/Linux) > > iEYEARECAAYFAk05+ssACgkQe+cmRQ8+KPfQnACaAr1YGFoiUmRrmz1/W+eTB8ly > 3b0AoInVelg2TYu1J3QpDj3WfO0Ko5zW > =vh8b > -END PGP SIGNATURE- > > -- > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > Finally, a world-class log management solution at an even better price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Trouble with contour plot
On Fri, Oct 29, 2010 at 7:44 AM, Nikolaus Rath wrote: > Benjamin Root writes: > > On Thu, Oct 28, 2010 at 3:31 PM, Nikolaus Rath < > nikolaus-bth8mxji...@public.gmane.org> wrote: > > > >> Hello, > >> > >> I'm having a weird problem with a contour plot. Consider the following > >> plots: > >> > >> import cPickle as pickle > >> import matplotlib.pyplot as plt > >> (Theta, Phi, Bnormal) = pickle.load(open('trouble.pickle', 'rb')) > >> plt.figure(0) > >> for i in [0, 300]: > >>plt.plot(Theta, Bnormal[:, i], label='Bnormal at Phi=%.3g' % Phi[i]) > >> > >> plt.ylabel('Theta') > >> plt.legend() > >> plt.savefig('figure0.png') > >> plt.figure(1) > >> plt.contourf(Phi, Theta, Bnormal) > >> plt.xlabel('Phi') > >> plt.ylabel('Theta') > >> plt.colorbar() > >> plt.savefig('figure1.png') > >> > >> The 'trouble.pickle' file is available on > >> http://www.rath.org/trouble.pickle. At Phi=0 the contour plot agrees > >> with the crossection (both show an n=7 oscillation), but at Phi=1.68 the > >> contour plot shows a uniform value while the crossection shows a phase > >> shifted version of oscillation at Phi=0. > >> > >> It seems to me that this is a blatant contradiction. > >> > >> > >> I have also uploaded the two figures at http://www.rath.org/figure1.png > >> and http://www.rath.org/figure0.png. > >> > >> > >> Am I missing something, or is this a bug? > >> > >> $ python --version > >> Python 2.6.5 > >> $ python -c 'import matplotlib; print matplotlib.__version__' > >> 1.0.0 > >> > >> > >> Thanks, > >> > >> -Nikolaus > >> > >> > > Nikolaus, > > > > What might be happening is that the Theta variable isn't monotonic. It > > first goes from zero to pi, then from -pi to 0. This also explains the > odd > > lines that appear in the line plots at the top and bottom. Try reforming > > your arrays so that the domain is monotonic (note that you will have to > > adjust the Phi and the Bnormal arrays as well because they were arranged > > assuming a certain domain from Theta. > > Indeed, this was the problem. Thank you very much! > > > However, it seems to me that this is quite a serious bug. The contour > documentation on > > http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.contour > does not mention this requirement, and obviously the contour method > itself does not even bother to check if its arguments are monotonically > increasing. Instead, it just *silently* produces garbage that in some > cases even looks like plausible data(!). > > Am I missing something here? Otherwise I'll report this on the bug > tracker. I think this should be documented and contour() should check > its input and raise a ValueError if it's not monotonic. > > > > Best, > > -Nikolaus > > Nikolaus, You are right, the documentation is seriously lacking and woefully out-of-date. It still claims that it can not handle internal regions correctly with masked arrays (I am pretty sure that is fixed) and it says nothing of any characteristics of X and Y. I also don't like how contourf() things are in the doc string for contour() and things that are for contour() are in contourf(). I wonder if we can do a much better job arranging this documentation. I don't know if there are any strict requirement on monotonicity for X and Y, or if there are any cases where the plot is still valid even if that property is violated. If it is a requirement, then I agree that there should be a check. Ben Root P.S. - I find that in many cases, contourf() is the wrong function to use for such plots, and find pcolor() (or one of its variants) to be better suited. Don't know what is better for you in your case, but it might be something to investigate. -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users