[Matplotlib-users] Plotting boolean/logical data type
Hello, I'v made a small program which plots data from a CAN-bus log file. Some of the data to plot is logical type on/off values (bit on or off). I have tried to find a way to plot this kind of data with no success. Basically what I want to do is to draw a horizontal line with relative y co-ordinates and absolute xmin and xmax co-ordinate. Then I could draw a line when a bit is high and have it always in plot area even when zooming etc. Like axhline(...) but with relative y and absolute x co-ordinates. Another way to do this could be using subplots, but I can't figure out how to use same x-scale on the both plots. Any suggestions? Best Regards Timo -- Download Intel#174; 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
Re: [Matplotlib-users] Problems seeing a png created with matplotlib in firefox
Hi, thanks a lot for your help, tips and investigations, but I still have the problem. It looks like this cannot be reproduced somewhere else, but I found out that I can see image with a dpi larger than 64 in the figsave command. Anything with a dpi of 64 or smaller is just white. See: http://atlas1.atlas.aei.uni-hannover.de/~dietz/Test/Subtest/ Cheers Alex On Tue, Mar 2, 2010 at 20:47, Renato Alves rjal...@igc.gulbenkian.pt wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Quoting Alexander Dietz on 03/02/2010 02:17 PM: Hi, that is very interesting. So what about the following image: test_large.png which has been create with the exact same code. Does this file has an alpha channel? Because this file I can see clearly on my browser. Yes, it does. Try running 'file name_of_file' on the console. You will RGB in one case and RGBA in the other. I ran a few tests on the files and they all look fine. No corruption. So it has to be something on your firefox... if you use a custom build, try recompiling it. Something could have gone wrong in the first run. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkuNa2IACgkQYh11EUYTX9RhWACgmMj3pkqJOH2gJn8CYH8pRlnI a54An3S4zxj4vLO8v+4WobeoO5UPOUkq =f3Na -END PGP SIGNATURE- -- Download Intel#174; 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
Re: [Matplotlib-users] skipping mpl-axes-interaction during key_press_event's
On Wednesday 03 March 2010 19:10:10 Matthias Michler wrote: Hello list, I'd like to bring something back, which was discussed in sep-dec 2008 OSX 10.5 event.key bug, which was initially posted by James Schombert. Did I miss any development in this field? I tried to implement the latest proposal, which allows you to switch off the mpl-axes-interaction during key_press_event's for a specific axes using ax.set_auto_key_press(False) Therefore I changed the backend_bases.py and the axes.py (see attachement). If this is a suitable solution, one could switch off the mpl-axes-interaction during key_press_event's for all axes belonging to a button, slider, ... . I attached an updated version of my patch including the handling of key-events, which have no axes associated (patch against svn-HEAD and maintance branch). Kind regards, Matthias Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8178) +++ lib/matplotlib/axes.py (working copy) @@ -457,8 +457,8 @@ self._cachedRenderer = None self.set_navigate(True) self.set_navigate_mode(None) +self.set_auto_key_press(True) - if xscale: self.set_xscale(xscale) if yscale: @@ -2404,6 +2404,20 @@ self._navigate_mode = b +def set_auto_key_press(self, b): + +Enable / Disable processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +self._auto_key_press = b + +def get_auto_key_press(self, b): + +Get current status of processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +return self._auto_key_press + def start_pan(self, x, y, button): Called when a pan operation has started. Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8178) +++ lib/matplotlib/backend_bases.py (working copy) @@ -1883,6 +1883,9 @@ def key_press(self, event): +if event.inaxes and event.inaxes._auto_key_press is False: +return + # these bindings happen whether you are over an axes or not #if event.key == 'q': #self.destroy() # how cruel to have to destroy oneself! Index: lib/matplotlib/axes.py === --- lib/matplotlib/axes.py (revision 8178) +++ lib/matplotlib/axes.py (working copy) @@ -461,8 +461,8 @@ self._cachedRenderer = None self.set_navigate(True) self.set_navigate_mode(None) +self.set_auto_key_press(True) - if xscale: self.set_xscale(xscale) if yscale: @@ -2424,6 +2424,20 @@ self._navigate_mode = b +def set_auto_key_press(self, b): + +Enable / Disable processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +self._auto_key_press = b + +def get_auto_key_press(self, b): + +Get current status of processing of key-press events in +backend_bases.FigureManagerBase.key_press for this axes. + +return self._auto_key_press + def start_pan(self, x, y, button): Called when a pan operation has started. Index: lib/matplotlib/backend_bases.py === --- lib/matplotlib/backend_bases.py (revision 8178) +++ lib/matplotlib/backend_bases.py (working copy) @@ -1677,6 +1677,9 @@ def key_press(self, event): +if event.inaxes and event.inaxes._auto_key_press is False: +return + # these bindings happen whether you are over an axes or not #if event.key == 'q': #self.destroy() # how cruel to have to destroy oneself! -- Download Intel#174; 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
Re: [Matplotlib-users] Runtime customization of plots
Andrea Gavana a écrit : Only the second approach slightly resembles what I have in mind. Navigating the plot using shortcuts and the MPL toolbars is less than 1% of what you can do to customize a MPL plot. Asking a user who knows nothing about Python (or programming in general) to use the IPython shell to modify the plot in runtime is unrealistic at best. The second approach looks interesting (pity it's been done using Qt, but then, the world is not perfect either...). I could use some of that code to build something that looks like a *beginning* of a possible customization of plots (using THE GUI toolkit). I thought this issue could have been important, as any other 2D/3D plotting toolkits (commercial and not commercial) have some (or a lot) of ability to customize their plots once they have been generated... Andrea. Jeremy Sanders initially developed Veusz as backend to Matplotlib but this branch was temporarily abandoned to restart recently. Matplotlib is THE reference library for scientific graphics under python and Veusz is also an EXCELLENT GUI app for scientific graphics. I think that Veusz+Matplolib could considerably widen their fields of application and theirs user's community if Matplotlib was used as a backend by default. This had already been spoken in veusz's mailing list and after these exchanges a new experimental branch (based on Matplotlib) was born. IMHO Matplotlib has now the object-orientated structure to easily use it for this purpose. Furthermore it now has 3d support as well as quiver plot and much more to offer. https://mail.gna.org/public/veusz-discuss/2009-04/msg5.html https://code.launchpad.net/veusz/experimental You could also see what Pierre Raybaut has already done with Spyder http://code.google.com/p/spyderlib/ Regards Francois attachment: francois_beaubert.vcf-- Download Intel#174; 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] how to insert a part of a plot in the same figure
Hey All, I have a fig, see attach image. I am plotting the number of infected nodes versus time. Time is running from 0 to 100. I need to insert a subplot in that figure that shows me the number of infected nodes for time running from 0 to 20 for example. If there is an example that can do the same thing I want please post it to me or tell me how I can do it in matplotlib. Cheers. http://old.nabble.com/file/p27780169/simbara-0%2B.41667-0-0.11-0.13-0.15-0.18.png -- View this message in context: http://old.nabble.com/how-to-insert-a-part-of-a-plot-in-the-same-figure-tp27780169p27780169.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; 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
Re: [Matplotlib-users] how to insert a part of a plot in the same figure
On Thursday 04 March 2010 13:35:12 kamaleon wrote: Hey All, I have a fig, see attach image. I am plotting the number of infected nodes versus time. Time is running from 0 to 100. I need to insert a subplot in that figure that shows me the number of infected nodes for time running from 0 to 20 for example. If there is an example that can do the same thing I want please post it to me or tell me how I can do it in matplotlib. Cheers. http://old.nabble.com/file/p27780169/simbara-0%2B.41667-0-0.11-0.13-0.15-0. 18.png I would add an additional axes 'ax2' with different x/y-limits and plot all data to this axes. ax1 = axes() ax2 = axes([0.4, 0.4, 0.4, 0.4]) # rectangle [left, bottom, width, height] in normalized (0, 1) units ax1.plot(arange(100)) draw() ax2.plot(arange(100)) draw() ax2.set_xlim(0, 20) draw() Kind regards, Matthias -- Download Intel#174; 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] Older Version of Matplotlib for Python 2.2.1
Hi there, I was searching for an older version of matplotlib for using it with python 2.2.1 (parts of the project can only be interpreted with this old version :(). Is there a package for an installation under windows (just like the current versions)? I tried to build 0.80 and 0.87 from the sources and had no success. Thx for any help! Greetings Andreas iSyst Intelligente Systeme GmbH Nordostpark 91 | 90411 Nuernberg Geschaeftsfuehrer: Prof. Dr.-Ing. Hans Rauch, Christine Rauch, Daniel Heinrich Sitz der Gesellschaft: Nuernberg Registergericht: Amtsgericht Nuernberg HRB 17887 Steuernr. 241/129/40894 | USt-IdNr.: DE212895677 -- Download Intel#174; 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
Re: [Matplotlib-users] how to insert a part of a plot in the same figure
Thanks Matthias, this seems help me. But how to remove the xlabel, ylable and the tilte in the subplot? Cheers Matthias Michler wrote: On Thursday 04 March 2010 13:35:12 kamaleon wrote: Hey All, I have a fig, see attach image. I am plotting the number of infected nodes versus time. Time is running from 0 to 100. I need to insert a subplot in that figure that shows me the number of infected nodes for time running from 0 to 20 for example. If there is an example that can do the same thing I want please post it to me or tell me how I can do it in matplotlib. Cheers. http://old.nabble.com/file/p27780169/simbara-0%2B.41667-0-0.11-0.13-0.15-0. 18.png I would add an additional axes 'ax2' with different x/y-limits and plot all data to this axes. ax1 = axes() ax2 = axes([0.4, 0.4, 0.4, 0.4]) # rectangle [left, bottom, width, height] in normalized (0, 1) units ax1.plot(arange(100)) draw() ax2.plot(arange(100)) draw() ax2.set_xlim(0, 20) draw() Kind regards, Matthias -- Download Intel#174; 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 -- View this message in context: http://old.nabble.com/how-to-insert-a-part-of-a-plot-in-the-same-figure-tp27780169p27782907.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; 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
Re: [Matplotlib-users] Older Version of Matplotlib for Python 2.2.1
what kind of errors did you get when building on windows? I recently found out that Visual Studio is required to build MPL on windows. This is because MPL contains C++ sources. Additionally, you must have the same version of Visual Studio that was used to build Python. So if you installed python 2.2.1 from a windows installer, then you will have to find out which version of Visual Studio to use. But I think if you build python yourself, then you can use whatever version of Visual Studio you want. This is the error you get when you have the wrong version of Visual Studio. At least in Python 2.6. The error message may be different in older versions of python. error: Unable to find vcvarsall.bat -Ben From: Schnappauf, Andreas [mailto:andreas.schnapp...@isyst.de] Sent: Thursday, March 04, 2010 9:04 AM To: matplotlib-users@lists.sourceforge.net Subject: [Matplotlib-users] Older Version of Matplotlib for Python 2.2.1 Hi there, I was searching for an older version of matplotlib for using it with python 2.2.1 (parts of the project can only be interpreted with this old version :(). Is there a package for an installation under windows (just like the current versions)? I tried to build 0.80 and 0.87 from the sources and had no success. Thx for any help! Greetings Andreas iSyst Intelligente Systeme GmbH Nordostpark 91 | 90411 Nuernberg Geschaeftsfuehrer: Prof. Dr.-Ing. Hans Rauch, Christine Rauch, Daniel Heinrich Sitz der Gesellschaft: Nuernberg Registergericht: Amtsgericht Nuernberg HRB 17887 Steuernr. 241/129/40894 | USt-IdNr.: DE212895677 -- Download Intel#174; 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
Re: [Matplotlib-users] how to insert a part of a plot in the same figure
On Thursday 04 March 2010 17:11:54 kamaleon wrote: Thanks Matthias, this seems help me. But how to remove the xlabel, ylable and the tilte in the subplot? Cheers Matthias Michler wrote: On Thursday 04 March 2010 13:35:12 kamaleon wrote: [...] Hi , what do you mean by xlabel, ylabel and title? In my example these were not set. In case you set them, you can remove them using xlabel('') ylabel('') title('') or do you mean the ticks and tick-labels on the axes? These can be removed using xticks([ ]) ytick([ ]) Kind regards, Matthias -- Download Intel#174; 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] Transform problem with fixed aspect ratio
Hi list - I've got a need to add several axes instances (e.g., barplots) to an existing figure. These additional axes need to be placed relative to data points on that plot. A problem occurs if the aspect ratio of the parent axes is set to a fixed value rather than using 'auto'. The attached script illustrates the problem with a pair of plots. Both plot a single red dot on the parent figure. A subplot is then placed directly on top of this point and a single point is plotted there, in green. If all's well you shouldn't see the red dot and should just see the green dot. In figure 2, where the aspect ratio is fixed, the subplot does not get placed at the correct location. Have I stumbled onto a subtlety of transforms that I'm not accounting for or is this perhaps a bug? matplotlib version 0.99.1 on linux; numpy 1.2.1 thanks a lot, -mike import matplotlib.pyplot as plt def add_inset(ax,ij): # Define a composite transform to go from data space in the Axes # instance to figure coordinates. # We need to perform a composite transform to get the location: # data to display followed by display to figure (because axes()) # takes a rect for positions relative to the figure compTrans = ax.transData + ax.get_figure().transFigure.inverted() # Place a subplot centered on the specified location with a fixed size # (relative to the size of the figure) # The green dot we plot here should cover up the red dot on the plot # underneath this one. We have a problem if they don't align. width=0.1 height=0.1 x,y = compTrans.transform(ij) bbox = [x-width/2.,y-height/2.,width,height] ax2 = plt.axes(bbox,axisbg='none') ax2.plot(0.5,0.5,'go') ax2.set_xlim((0,1)) ax2.set_ylim((0,1)) return ax2 def alter_appearance(ax,ij): ax.set_xlim((0,10)) ax.set_ylim((0,10)) ax.axhline(y=ij[1],color='0.7') ax.axvline(x=ij[0],color='0.7') ij = (7,5) f = plt.gcf() f.add_subplot(211) plt.plot(ij[0],ij[1],'ro') ax = plt.gca() ax.set_title('Auto aspect ratio') alter_appearance(ax,ij) add_inset(ax,ij) f.add_subplot(212) plt.plot(ij[0],ij[1],'ro') ax = plt.gca() ax.set_title('Fixed aspect ratio') ax.set_aspect(1.5,adjustable='box') alter_appearance(ax,ij) add_inset(ax,ij) plt.show() -- Download Intel#174; 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
Re: [Matplotlib-users] how to insert a part of a plot in the same figure
Thanks you put it right, I wanted to know how to remove them inside the subplot. It is done. Cheers Matthias Michler wrote: On Thursday 04 March 2010 17:11:54 kamaleon wrote: Thanks Matthias, this seems help me. But how to remove the xlabel, ylable and the tilte in the subplot? Cheers Matthias Michler wrote: On Thursday 04 March 2010 13:35:12 kamaleon wrote: [...] Hi , what do you mean by xlabel, ylabel and title? In my example these were not set. In case you set them, you can remove them using xlabel('') ylabel('') title('') or do you mean the ticks and tick-labels on the axes? These can be removed using xticks([ ]) ytick([ ]) Kind regards, Matthias -- Download Intel#174; 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 -- View this message in context: http://old.nabble.com/how-to-insert-a-part-of-a-plot-in-the-same-figure-tp27780169p27784306.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Download Intel#174; 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] colorbar on LEFT side of figure ?
Hi, I have been unable to place a colorbar on the LEFT side of a figure. For example, in the Gaussian noise with vertical colorbar http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html demo, how can the colorbar be positioned on the left side of the figure. Thanks, -- jv -- Download Intel#174; 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
Re: [Matplotlib-users] colorbar on LEFT side of figure ?
Jim Vickroy wrote: Hi, I have been unable to place a colorbar on the LEFT side of a figure. For example, in the Gaussian noise with vertical colorbar http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html demo, how can the colorbar be positioned on the left side of the figure. Thanks, -- jv Create your own axes instance for the colorbar (as in http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html). -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 -- Download Intel#174; 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
Re: [Matplotlib-users] Plotting boolean/logical data type
Do you want something like the attached? I created it with my package that no-one wants :-( import diagram_cl import diagram_cl.kernels.tk import numpy import Tkinter d1 = diagram_cl.Diagram() series = (numpy.random.random(100) 0.5).astype(numpy.float) for idx in xrange(0, len(series)): ... layer = diagram_cl.Layer2D(x = [0, series[idx]], y = [idx, idx], color = 'blue') ... d1.add_layer(layer) ... tk = Tkinter.Tk() k1 = diagram_cl.kernels.tk.Diagram(tk, d1) Double-right click on the figure, Save, 200x200, Bits.png. But of course, you can also do it with normal matplotlib (I'm not used to the pyplot things though, I'm rather using purist's API): Hmm, that's why it would be not the standard way to do it, so can anyone else post pure matplotlib means? Friedrich attachment: Bits.png-- Download Intel#174; 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
Re: [Matplotlib-users] Transform problem with fixed aspect ratio
With axes aspect_ratio set, the position of the axes is determined during the drawing time. And the position of the inset axes also need to be adjusted during the drawing time to incorporate this, One way to archive this is to set axes_locator attribute, which accept a callable object that returns the position of the axes. Here is a slightly modified version of your add_inset. def add_inset(ax,ij): # Define a composite transform to go from data space in the Axes # instance to figure coordinates. # We need to perform a composite transform to get the location: # data to display followed by display to figure (because axes()) # takes a rect for positions relative to the figure def my_axes_locator(axes, renderer): compTrans = ax.transData + ax.get_figure().transFigure.inverted() width=0.1 height=0.1 x,y = compTrans.transform(ij) bbox = [x-width/2.,y-height/2.,width,height] return bbox # Place a subplot centered on the specified location with a fixed size # (relative to the size of the figure) # The green dot we plot here should cover up the red dot on the plot # underneath this one. We have a problem if they don't align. ax2 = plt.axes([0,0,1,1],axisbg='none', axes_locator=my_axes_locator) ax2.plot(0.5,0.5,'go') ax2.set_xlim((0,1)) ax2.set_ylim((0,1)) return ax2 Regards, -JJ On Thu, Mar 4, 2010 at 12:53 PM, Mike Kay vdot...@gmail.com wrote: Hi list - I've got a need to add several axes instances (e.g., barplots) to an existing figure. These additional axes need to be placed relative to data points on that plot. A problem occurs if the aspect ratio of the parent axes is set to a fixed value rather than using 'auto'. The attached script illustrates the problem with a pair of plots. Both plot a single red dot on the parent figure. A subplot is then placed directly on top of this point and a single point is plotted there, in green. If all's well you shouldn't see the red dot and should just see the green dot. In figure 2, where the aspect ratio is fixed, the subplot does not get placed at the correct location. Have I stumbled onto a subtlety of transforms that I'm not accounting for or is this perhaps a bug? matplotlib version 0.99.1 on linux; numpy 1.2.1 thanks a lot, -mike -- Download Intel#174; 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 -- Download Intel#174; 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
Re: [Matplotlib-users] Plotting boolean/logical data type
Not sure what exactly you want. Is this close? ax = subplot(111) tr = ax.get_xaxis_transform() ax.plot([0.2, 0.8], [0.5, 0.5], transform=tr) The x-coodinate is in data coordinate, but y coordinate is in (normalized) axes coordinate. More about the transforms behind matplotlib can be found in http://matplotlib.sourceforge.net/trunk-docs/users/transforms_tutorial.html -JJ On Thu, Mar 4, 2010 at 3:10 AM, Timo Heine timo.he...@gmail.com wrote: Hello, I'v made a small program which plots data from a CAN-bus log file. Some of the data to plot is logical type on/off values (bit on or off). I have tried to find a way to plot this kind of data with no success. Basically what I want to do is to draw a horizontal line with relative y co-ordinates and absolute xmin and xmax co-ordinate. Then I could draw a line when a bit is high and have it always in plot area even when zooming etc. Like axhline(...) but with relative y and absolute x co-ordinates. Another way to do this could be using subplots, but I can't figure out how to use same x-scale on the both plots. Any suggestions? Best Regards Timo -- Download Intel#174; 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 -- Download Intel#174; 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] Change colorbar orientation once drawn
Hi, I would like to change the orientation of a colorbar once it has already been drawn. So for example if I create the colorbar with: cb = fig.colorbar(mappable=image, cax=cax, orientation='vertical') I would like to be able to do cb.set_orientation('horizontal') Is there a way to do this, since set_orientation does not exist? Thanks for any help, Thomas -- Download Intel#174; 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] Using callbacks to change Axes positions
Hi, I am trying to set up a colorbar that automatically resizes if I zoom in to an image (which changes the aspect ratio of the axes, so I want the colorbar to get resized too). Let's say I have two Axes instances, say ax (for the main image) and cax (for the colorbar). I can set up a callback if the view limits in one axes change, for example ax.callbacks.connect('xlim_changed', update_colorbar) ax.callbacks.connect('ylim_changed', update_colorbar) Now I can store a reference to cax inside ax: ax._cax = cax And I can now define update_colorbar so that it basically changes the position of cax: def update_colorbar(ax): # Get current position xmin = ax..get_position().xmin ... # Compute new colorbar position ... # Set new position ax._cax.set_position(...) # Return axes instance return ax Now the issue is that if I select a region of the image to zoom into, then as soon as I've selected the region, update_colorbar gets called, but by then, the aspect ratio of ax hasn't changed, and so the position I find when I do xmin = ax..get_position().xmin in update_colorbar is the *old* position of ax, not the new one. So the colorbar position is always one step behind compared to the main image axes. Can anyone think of any way that would avoid this issue, and to be able to use the *new* position of ax inside update_colorbar? Thanks in advance for any help, Thomas -- Download Intel#174; 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] Mysterious ValueError: zero-size array...
Hi, folks! Let's see, first the tech stuff: Python version - 2.5.4; matplotlib version - 0.99.0; numpy version - 1.4.0; Platform: 32 bit Windows Vista Home Premium SP2. OK, now for the problem: imshow is (indirectly) raising ValueError: zero-size array to ufunc.reduce without identity. Here's the traceback: Traceback (most recent call last): File mycode, line 108, in module ax.imshow(part2plot, cmap_name, extent = extent) File C:\Python254\lib\site-packages\matplotlib\axes.py, line 6261, in imshow im.autoscale_None() File C:\Python254\lib\site-packages\matplotlib\cm.py, line 236, in autoscale_None self.norm.autoscale_None(self._A) File C:\Python254\lib\site-packages\matplotlib\colors.py, line 792, in autoscale_None if self.vmin is None: self.vmin = ma.minimum(A) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line , in __call__ return self.reduce(a) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line 5570, in reduce t = self.ufunc.reduce(target, **kargs) ValueError: zero-size array to ufunc.reduce without identity Script terminated. And here's the local code (it may be difficult to generate a self-contained reproducer of the problem, so I'm postponing that 'til it appears absolutely necessary): ax.hold(True) for i in range(4): for j in range(4): part2plot = argW[j*ny/4:(j+1)*ny/4, i*nx/4:(i+1)*nx/4] if N.any(N.logical_not(N.isfinite(part2plot))): print i, j, print N.argwhere(N.logical_not(N.isfinite(part2plot))) extent = (i*nx/4, (i+1)*nx/4, (j+1)*ny/4, j*ny/4) ax.imshow(part2plot, cmap_name, extent = extent) I added the print statements because Googling the error, I found an indication that if my image array contained any NaN's, that might be the cause; sure enough, I did have some, but I eliminated them, and now nothing gets printed before the exception is raised, so, unless I'm missing something obvious (wouldn't be the first time ;-)) something else is the problem. Any ideas? Thanks! DG -- Download Intel#174; 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] Mysterious ValueError: zero-size array...
Hi, folks! Let's see, first the tech stuff: Python version - 2.5.4; matplotlib version - 0.99.0; numpy version - 1.4.0; Platform: 32 bit Windows Vista Home Premium SP2. OK, now for the problem: imshow is (indirectly) raising ValueError: zero-size array to ufunc.reduce without identity. Here's the traceback: Traceback (most recent call last): File mycode, line 108, in module ax.imshow(part2plot, cmap_name, extent = extent) File C:\Python254\lib\site-packages\matplotlib\axes.py, line 6261, in imshow im.autoscale_None() File C:\Python254\lib\site-packages\matplotlib\cm.py, line 236, in autoscale_None self.norm.autoscale_None(self._A) File C:\Python254\lib\site-packages\matplotlib\colors.py, line 792, in autoscale_None if self.vmin is None: self.vmin = ma.minimum(A) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line , in __call__ return self.reduce(a) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line 5570, in reduce t = self.ufunc.reduce(target, **kargs) ValueError: zero-size array to ufunc.reduce without identity Script terminated. And here's the local code (it may be difficult to generate a self-contained reproducer of the problem, so I'm postponing that 'til it appears absolutely necessary): ax.hold(True) for i in range(4): for j in range(4): part2plot = argW[j*ny/4:(j+1)*ny/4, i*nx/4:(i+1)*nx/4] if N.any(N.logical_not(N.isfinite(part2plot))): print i, j, print N.argwhere(N.logical_not(N.isfinite(part2plot))) extent = (i*nx/4, (i+1)*nx/4, (j+1)*ny/4, j*ny/4) ax.imshow(part2plot, cmap_name, extent = extent) I added the print statements because Googling the error, I found an indication that if my image array contained any NaN's, that might be the cause; sure enough, I did have some, but I eliminated them, and now nothing gets printed before the exception is raised, so, unless I'm missing something obvious (wouldn't be the first time ;-)) something else is the problem. Any ideas? Thanks! DG -- Download Intel#174; 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
Re: [Matplotlib-users] Using callbacks to change Axes positions
see http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg15919.html axes_grid toolkit provides some helper function that utilizes axes_locator (take a look at demo_locatable_axes_easy function in the example below) http://matplotlib.sourceforge.net/examples/axes_grid/demo_axes_divider.html -JJ On Thu, Mar 4, 2010 at 9:05 PM, Thomas Robitaille thomas.robitai...@gmail.com wrote: Hi, I am trying to set up a colorbar that automatically resizes if I zoom in to an image (which changes the aspect ratio of the axes, so I want the colorbar to get resized too). Let's say I have two Axes instances, say ax (for the main image) and cax (for the colorbar). I can set up a callback if the view limits in one axes change, for example ax.callbacks.connect('xlim_changed', update_colorbar) ax.callbacks.connect('ylim_changed', update_colorbar) Now I can store a reference to cax inside ax: ax._cax = cax And I can now define update_colorbar so that it basically changes the position of cax: def update_colorbar(ax): # Get current position xmin = ax..get_position().xmin ... # Compute new colorbar position ... # Set new position ax._cax.set_position(...) # Return axes instance return ax Now the issue is that if I select a region of the image to zoom into, then as soon as I've selected the region, update_colorbar gets called, but by then, the aspect ratio of ax hasn't changed, and so the position I find when I do xmin = ax..get_position().xmin in update_colorbar is the *old* position of ax, not the new one. So the colorbar position is always one step behind compared to the main image axes. Can anyone think of any way that would avoid this issue, and to be able to use the *new* position of ax inside update_colorbar? Thanks in advance for any help, Thomas -- Download Intel#174; 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 -- Download Intel#174; 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] Mysterious ValueError: zero-size array...
Hi, folks! Let's see, first the tech stuff: Python version - 2.5.4; matplotlib version - 0.99.0; numpy version - 1.4.0; Platform: 32 bit Windows Vista Home Premium SP2. OK, now for the problem: imshow is (indirectly) raising ValueError: zero-size array to ufunc.reduce without identity. Here's the traceback: Traceback (most recent call last): File mycode, line 108, in module ax.imshow(part2plot, cmap_name, extent = extent) File C:\Python254\lib\site-packages\matplotlib\axes.py, line 6261, in imshow im.autoscale_None() File C:\Python254\lib\site-packages\matplotlib\cm.py, line 236, in autoscale_None self.norm.autoscale_None(self._A) File C:\Python254\lib\site-packages\matplotlib\colors.py, line 792, in autoscale_None if self.vmin is None: self.vmin = ma.minimum(A) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line , in __call__ return self.reduce(a) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line 5570, in reduce t = self.ufunc.reduce(target, **kargs) ValueError: zero-size array to ufunc.reduce without identity Script terminated. And here's the local code (it may be difficult to generate a self-contained reproducer of the problem, so I'm postponing that 'til it appears absolutely necessary): ax.hold(True) for i in range(4): for j in range(4): part2plot = argW[j*ny/4:(j+1)*ny/4, i*nx/4:(i+1)*nx/4] if N.any(N.logical_not(N.isfinite(part2plot))): print i, j, print N.argwhere(N.logical_not(N.isfinite(part2plot))) extent = (i*nx/4, (i+1)*nx/4, (j+1)*ny/4, j*ny/4) ax.imshow(part2plot, cmap_name, extent = extent) I added the print statements because Googling the error, I found an indication that if my image array contained any NaN's, that might be the cause; sure enough, I did have some, but I eliminated them, and now nothing gets printed before the exception is raised, so, unless I'm missing something obvious (wouldn't be the first time ;-)) something else is the problem. Any ideas? Thanks! DG -- Download Intel#174; 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] Mysterious ValueError: zero-size array...
Hi, folks! Let's see, first the tech stuff: Python version - 2.5.4; matplotlib version - 0.99.0; numpy version - 1.4.0; Platform: 32 bit Windows Vista Home Premium SP2. OK, now for the problem: imshow is (indirectly) raising ValueError: zero-size array to ufunc.reduce without identity. Here's the traceback: Traceback (most recent call last): File mycode, line 108, in module ax.imshow(part2plot, cmap_name, extent = extent) File C:\Python254\lib\site-packages\matplotlib\axes.py, line 6261, in imshow im.autoscale_None() File C:\Python254\lib\site-packages\matplotlib\cm.py, line 236, in autoscale_None self.norm.autoscale_None(self._A) File C:\Python254\lib\site-packages\matplotlib\colors.py, line 792, in autoscale_None if self.vmin is None: self.vmin = ma.minimum(A) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line , in __call__ return self.reduce(a) File C:\Python254\Lib\site-packages\numpy\ma\core.py, line 5570, in reduce t = self.ufunc.reduce(target, **kargs) ValueError: zero-size array to ufunc.reduce without identity Script terminated. And here's the local code (it may be difficult to generate a self-contained reproducer of the problem, so I'm postponing that 'til it appears absolutely necessary): ax.hold(True) for i in range(4): for j in range(4): part2plot = argW[j*ny/4:(j+1)*ny/4, i*nx/4:(i+1)*nx/4] if N.any(N.logical_not(N.isfinite(part2plot))): print i, j, print N.argwhere(N.logical_not(N.isfinite(part2plot))) extent = (i*nx/4, (i+1)*nx/4, (j+1)*ny/4, j*ny/4) ax.imshow(part2plot, cmap_name, extent = extent) I added the print statements because Googling the error, I found an indication that if my image array contained any NaN's, that might be the cause; sure enough, I did have some, but I eliminated them, and now nothing gets printed before the exception is raised, so, unless I'm missing something obvious (wouldn't be the first time ;-)) something else is the problem. Any ideas? Thanks! DG -- Download Intel#174; 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