Re: [Matplotlib-users] rationale for contour() argument dimensions?
Chris, The point is that contouring and gridding are two entirely separate operations--and this is true in general, not just for matplotlib. Contouring algorithms--at least all the ones I have looked at--work with data on a regular grid. There are many ways to map scattered data to a regular grid, so it makes sense to do this as a separate step, so you can choose a gridding method that works well for your particular type of data set. See http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data Now, if your data are already on a quadrilateral grid, as in the example you give, but your arrays have been flattened, then all you need to do is reshape your arrays so that they are 2-D, with the row number corresponding to Y (vertical on the plot) and the column index corresponding to X (horizontal). Filling in your example below to include 2 values of x, and assuming all three variables are numpy ndarrays, you could do something like this: x.shape = 2,3 y.shape = 2,3 z.shape = 2,3 contour(x.transpose(), y.transpose(), z.transpose()) The transposes are needed because your original z is arranged with y varying fastest. Eric Chris wrote: I may be a bit thick, but I am having a heck of a time figuring out how to use contour() properly. Specifically, I do not see why the z dimension should be a 2d array. It should only take a set of x,y,z coordinates to produce a surface -- what is the extra dimension for? More importantly, how do I take canonical 3-d data, e.g.: x y z 1 1 2.3 1 2 4.5 1 3 6.1 2 1 7.3 . . . and get it into the form that matplotlib demands? Thanks, cf - 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 - 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] Axes3d
Mike, just a question about the new transforms backend -- can the input dimensionality be greater than 2? (I realize functions to do so probably don't currently exist, but the question is about the transforms machinery itself.) -Andrew Michael Droettboom wrote: I'm not very familiar with how axes3d works, but just by looking at the number of transform calls and objects, it appears that it will take significant effort to update it. It was never one of the goals of the transformation refactoring to have that working. Personally, I'm +1 on removing axes3d.py to avoid confusion. However, a motivated user could follow the information in API_CHANGES to update axes3d.py. I'd be happy to help if you got stuck, but I don't really have the motivation/mandate to do the whole thing myself. Cheers, Mike Matthias Michler wrote: Hello list, I know it is not recommended to use matplotlib for 3d plotting, but for a while simple plots worked fine for me. This is not the case with actual svn version and therefore my question is: Would it break at lost or cost much effort to make the 3d-plot-examples of the Cookbook work? if I try: [1] import matplotlib.axes3d as p3 I get the error attached below. Thanks for any advise in advance. best regards Matthias --- type 'exceptions.ImportError' Traceback (most recent call last) /home/michler/CompPhys_2008/Uebungsaufgaben/050_Antidot/3D_matplotlib/ipython console in module() /scratch/michler/SOFT/lib/python2.5/site-packages/matplotlib/axes3d.py in module() 14 from axes import Axes 15 import cbook --- 16 from transforms import unit_bbox 17 18 import numpy as np type 'exceptions.ImportError': cannot import name unit_bbox /scratch/michler/SOFT/lib/python2.5/site-packages/matplotlib/axes3d.py(16)module() 15 import cbook --- 16 from transforms import unit_bbox 17 - 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 - 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] More Matlab-like way to manipulate colormaps?
David, There is no such API--maybe we should add some methods to the base Colormap so there would be--but you can do it yourself in either of two ways. First, you can generate a colormap from a list of colors, and the colors can be rgb triplets, so you could make your Nx3 array, do whatever you want with it, and then turn it into a colormap by using it to initialize a ListedColormap. (The ListedColormap accepts an Nx3 array, or a list of any valid mpl colorspecs.) Second, if you have any existing mpl Colormap instance, you can directly manipulate the _lut attribute; it is an ndarray and its dimensions are (N+3)x4. You might want to manipulate only the [:N,:3] subarray of it. The leading underscore means this attribute is not intended for user manipulation--but there is nothing to stop you from doing it in a pinch if necessary. Eric David Goldsmith wrote: Hi. Making progress. Caveat for what follows: the last version of Matlab I used was like 6 or 7, I think - it's been a little while - so for all I know, the colormap manipulation API I've been able to discover in the current MPL does correspond closely to the same thing in the current Matlab. That said, said MPL colormap API is much more powerful (and consequently complicated) than I need, at least for right now. :-) Is there a set of tools I'm not finding, or perhaps a third-party add-on, that enables more Matlab-like colormap manipulation? For example, I'm use to a (Matlab) colormap simply being an Nx3 array of N RGB triples (or at least that's the API), which one can then process using standard array operators (+, *, etc.), methods (transpose, flipud, fliplr, etc), etc. and create and apply new colormaps by simply saying colormap = new N x 3 array - are there tools which enable this manner of manipulating MPL's colormap class instances? Or a built-in API to these that I'm not finding? Thanks! DG PS: In case this is relevant, I'm using the OO API, not pylab. Thanks again. - 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 - 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
[Matplotlib-users] picking a broken_barh collection calls pick event twice
If I click on a bar that is part of a broken_barh collection which has its picker attribute enabled, there appears to be two events generated for example: def on_pick(self, event): print event.mouseevent.xdata print event.mouseevent.ydata clicking on a bar will cause this method to be executed twice, hence I get something like this if I click just once: 5575.9722 0.02778 5575.9722 0.02778 Is there a workaround such that the method is executed only once? - 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] Axes3d
Michael Droettboom wrote: I'm not very familiar with how axes3d works, but just by looking at the number of transform calls and objects, it appears that it will take significant effort to update it. It was never one of the goals of the transformation refactoring to have that working. Personally, I'm +1 on removing axes3d.py to avoid confusion. I agree. This is overdue. Eric - 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] threading problems
On Sun, Jun 22, 2008 at 12:31 AM, Eric Firing [EMAIL PROTECTED] wrote: Scott, I think that for interactive work such as you describe, ipython -pylab pretty well solves the problem, and provides window behavior like matlab's. Yes, exactly. Those of you trying to make this work may want to read http://matplotlib.sf.net/interactive.html . - 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] threading problems
John Hunter-4 wrote: I think that for interactive work such as you describe, ipython -pylab pretty well solves the problem, and provides window behavior like matlab's. Yes, exactly. Those of you trying to make this work may want to read http://matplotlib.sf.net/interactive.html . Yes, iPython takes care of these issues in interactive use. I've been trying to stay on mainline Python for portable application development and was using the interactive Matlab scenario as an example of expected non-blocking behavior. Interactive use isn't the end-goal for me, or, I think, for Dan. The root issue is the need to keep other activities running while a plot window is open, which comes back to the blocking behavior of show(). It looks like the code linked in the previous post does the job; it just requires getting under the hood of GTK a bit more to use a separate manager function for each plot window. That's fine, and actually it seems it would be preferable as the default behavior of matplotlib (though each backend probaby requires unique code). There are other alternatives: plot to a file and display the image in a window, which loses the zoom/pan functions in matplotlib windows, or launch the matplotlib plot window as a separate process or program. Thanks, Scott -- View this message in context: http://www.nabble.com/threading-problems-tp18015447p18055354.html Sent from the matplotlib - users mailing list archive at Nabble.com. - 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] Axes3d
On Fri, Jun 20, 2008 at 12:12 PM, Eric Firing [EMAIL PROTECTED] wrote: transformation refactoring to have that working. Personally, I'm +1 on removing axes3d.py to avoid confusion. Done home:~/mpl/lib/matplotlib cat axes3d.py raise NotImplmentedError('axes3d is not supported in matplotlib-0.98. You may want to try the 0.91.x maintenance branch') - 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] More Matlab-like way to manipulate colormaps?
Thanks Eric. Yeah, I noticed the _lut attribute and conjectured that it was the most analogous structure. Can you please tell me more about it, e.g., why N+3? Is the fourth column an alpha spec? If so, would this be a way to give different colors different alpha values (which is something I want to be able to do; actually, what I want to do is to be able to specify a non-constant array of alpha values, i.e., I want direct pixel-to-pixel control over alpha values...) Anyway, I'll build some tools around it and submit as a patch for possible inclusion in future releases... DG --- On Sun, 6/22/08, Eric Firing [EMAIL PROTECTED] wrote: From: Eric Firing [EMAIL PROTECTED] Subject: Re: [Matplotlib-users] More Matlab-like way to manipulate colormaps? To: [EMAIL PROTECTED] Cc: matplotlib-users@lists.sourceforge.net Date: Sunday, June 22, 2008, 1:14 AM David, There is no such API--maybe we should add some methods to the base Colormap so there would be--but you can do it yourself in either of two ways. First, you can generate a colormap from a list of colors, and the colors can be rgb triplets, so you could make your Nx3 array, do whatever you want with it, and then turn it into a colormap by using it to initialize a ListedColormap. (The ListedColormap accepts an Nx3 array, or a list of any valid mpl colorspecs.) Second, if you have any existing mpl Colormap instance, you can directly manipulate the _lut attribute; it is an ndarray and its dimensions are (N+3)x4. You might want to manipulate only the [:N,:3] subarray of it. The leading underscore means this attribute is not intended for user manipulation--but there is nothing to stop you from doing it in a pinch if necessary. Eric David Goldsmith wrote: Hi. Making progress. Caveat for what follows: the last version of Matlab I used was like 6 or 7, I think - it's been a little while - so for all I know, the colormap manipulation API I've been able to discover in the current MPL does correspond closely to the same thing in the current Matlab. That said, said MPL colormap API is much more powerful (and consequently complicated) than I need, at least for right now. :-) Is there a set of tools I'm not finding, or perhaps a third-party add-on, that enables more Matlab-like colormap manipulation? For example, I'm use to a (Matlab) colormap simply being an Nx3 array of N RGB triples (or at least that's the API), which one can then process using standard array operators (+, *, etc.), methods (transpose, flipud, fliplr, etc), etc. and create and apply new colormaps by simply saying colormap = new N x 3 array - are there tools which enable this manner of manipulating MPL's colormap class instances? Or a built-in API to these that I'm not finding? Thanks! DG PS: In case this is relevant, I'm using the OO API, not pylab. Thanks again. - 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 - 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
[Matplotlib-users] Animated bar graph question
I'm very new to MPL, and I'm having a blast with it - great work. I've looked around the docs, lists and other random places for a hint on this, but I'm still stumped. The goal is simple: I'd like to create a very basic animated bar or barh chart. I've been playing via ion() from the IPython shell but I run into the following issue: The bar is painted correctly, but any value lower than the max doesn't show up, as the max value bar doesn't clear. For example, from IPython: bar(10+0.25, 10) shows perfectly, then an update (using interactive mode set to on) bar(10+0.25, 4) ...shows a new bar with a y value of 4, but the old bar (value 10) is still painted. As a result, it doesn't look quite right. Is there an easy way to clear the old max value bar? Thanks for any advice. Regards, Matt - 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] Animated bar graph question
Matt C wrote: I'm very new to MPL, and I'm having a blast with it - great work. I've looked around the docs, lists and other random places for a hint on this, but I'm still stumped. The goal is simple: I'd like to create a very basic animated bar or barh chart. I've been playing via ion() from the IPython shell but I run into the following issue: The bar is painted correctly, but any value lower than the max doesn't show up, as the max value bar doesn't clear. For example, from IPython: bar(10+0.25, 10) shows perfectly, then an update (using interactive mode set to on) bar(10+0.25, 4) Try adding a clf(), which clears the current figure, in between the calls to bar. Another option is to use hold(False) signals that you want a new plotting command to start from a clean slate. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma - 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] picking a broken_barh collection calls pick event twice
My guess is that clicking on a collection causes a pick event to be returned by the collection itself and also perhaps by the barh member in the collection. No idea if that's the case, but just for the record, I figured out a simple enough workaround in which the pick handler is disconnected to open a wxPython popup window. Once that window is closed, the pick handler is reconnected: self.evt_bind = self.canvas.mpl_connect('pick_event', self.on_pick) . . . . def on_pick(self, event): if type(event.artist) == brokenbarh: self.canvas.mpl_disconnect(self.evt_bind) popup = popupwin(self, event.mouseevent.xdata, event.mouseevent.ydata) popup.Popup() class popupwin(wx.PopupTransientWindow): def __init__(self, plot, x_coord, y_coord): wx.PopupTransientWindow.__init__(self, plot) self.plot = plot text = st.gen(self, 'hello') def OnDismiss(self): self.plot.evt_bind = self.plot.canvas.mpl_connect('pick_event', self.plot.on_pick On Sun, Jun 22, 2008 at 1:18 AM, Paul Hartley [EMAIL PROTECTED] wrote: If I click on a bar that is part of a broken_barh collection which has its picker attribute enabled, there appears to be two events generated for example: def on_pick(self, event): print event.mouseevent.xdata print event.mouseevent.ydata clicking on a bar will cause this method to be executed twice, hence I get something like this if I click just once: 5575.9722 0.02778 5575.9722 0.02778 Is there a workaround such that the method is executed only once? - 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
[Matplotlib-users] Font weight on axes/labels
I'm trying to adjust the font weight on some of my plots - I'd like to have the numbers along the axis ticks be bold instead of regular font like the default setting. The problem is, nothing I do seems to change the font weight. I've changed everything I can font in matplotlibrc to bold, and when I go in and explicitly look at the XTick or YTick objects and their text properties, it even claims the text is bold... yet the text is normal weight font when displayed on the plot. A would also like to have the plot labels be bolder, as well, and I can't seem to change that either. Note that I have usetex as True, and I realize that this means the labels, at least, are rendered through TeX... but I'm not clear on how I can change the font properties to render bold versions of all the TeX fonts I'm using (assuming this is possible). And I've been under the impression that the default number formattes, at least, don't render through TeX. So does anyone know how I can make all/any of my text elemens bold? - 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