Re: [Matplotlib-users] Error with 0.99.2 when using Intel Compiler (Linux)
Hi again, I've fixed the issue on my box. The issue lies in the definition of the hash_map. For ICC for Linux, the GCC headers should be used. Matthieu 2010/1/29 Matthieu Brucher matthieu.bruc...@gmail.com: Hi, It seems that the compilation of base_format needs a C++ compiler, but distutils launches icc instead of icpc. This may work with gcc, but with Intel Compiler, I can't force icc to understand C++. I don't know what happened between 0.98.5 and 0.99.2, but I can't use Matplotlib anymore :| Matthieu -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Draw data not in rectangular shape
Hi there, I've got a a pylab 2D array which I plot using imshow() which just works fine. But part of the data within the array is not to be considered nor plotted. To keep it simple let's assume the data I need is shaped like a triangle. It is no problem to extract the data from the matrix converting the matrix to a list and dropping all unnecessary data. My problem is that I don't know how to plot the data again. A possible work around would be to set data elements which I don't need to some value not in the data. But I since I need to compute histograms for the data, for example, I have to drop the data anyways. Is there a way to solve my problem? Thanks for your help. Cheers, Torsten -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Draw data not in rectangular shape
On 1 February 2010 11:34, Torsten Andre q...@takb.net wrote: I've got a a pylab 2D array which I plot using imshow() which just works fine. But part of the data within the array is not to be considered nor plotted. My problem is that I don't know how to plot the data again. Hi Torsten, Use NumPy masked arrays with imshow() [http://docs.scipy.org/doc/numpy/reference/maskedarray.html]. You can use the masked array just as you have been using your regular NumPy array, they are designed for this purpose and Matplotlib will not plot the masked portion of your data. The pylab interface actually imports numpy so your pylab array is really a NumPy ndarray object (try calling print type(your_pylab_array) to see this). Cheers, Scott -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Possible workaround for memory leak using pylab.figure(), pylab.show() ?
Hi, I have already submitted this issue as a possible problem to Tracker, however there is no response till now http://sourceforge.net/tracker/?func=detailaid=2940967group_id=80706atid=560720. Probably, someone could help me with possible workaround for this problem. I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak. Below is simple example: pylab.ion() for i in range(10): pylab.figure() pylab.draw() val = cbook.report_memory(i) print i, val pylab.ioff() the same loop is used for show(): for i in range(10): pylab.figure() pylab.plot([1,3]) val = cbook.report_memory(i) print i, val pylab.show() I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg. Thanks in advance, Tanja -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Possible workaround for memory leak using pylab.figure(), pylab.show() ?
Have you tried the pylab.close() this should force the flush of the memory. 2010/2/1 Tanja Gurzhiy tanja.gurz...@gmail.com Hi, I have already submitted this issue as a possible problem to Tracker, however there is no response till now http://sourceforge.net/tracker/?func=detailaid=2940967group_id=80706atid=560720. Probably, someone could help me with possible workaround for this problem. I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak. Below is simple example: pylab.ion() for i in range(10): pylab.figure() pylab.draw() val = cbook.report_memory(i) print i, val pylab.ioff() the same loop is used for show(): for i in range(10): pylab.figure() pylab.plot([1,3]) val = cbook.report_memory(i) print i, val pylab.show() I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg. Thanks in advance, Tanja -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Size of ellipses in EllipseCollection
Hi, I would like to plot lots of error ellipses on my plot. I thought I could use an EllipseCollection to do so, but I didn't manage to get the ellipse sizes, expressed in data units, right (see test script attached). When using a plain list of Ellipse's, everything looks fine: ells = [ P.matplotlib.patches.Ellipse(xy=xyi, width=wi, height=hi, angle=ai, edgecolor='b', facecolor='b', alpha=0.3) for xyi,wi,hi,ai in zip(xy,w,h,a)] for ell in ells: ax.add_artist(ell) But when using EllipseCollection (as explained in http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html), coll = P.matplotlib.collections.EllipseCollection(widths=w, heights=h, angles=a, units='x', offsets=xy, transOffset=ax.transData, edgecolor='r', facecolor='r', alpha=0.3) ax.add_collection(coll) the size of the ellipses (expressed in data units) appears incorrect, and depends furthermore of the aspect ratio of the figure (try pan/zoom or resize the interactive window). I naively thought the two approaches should give the same result... Did I miss something in the way to use EllipseCollections? Cheers, -- .~. Yannick COPIN (o:* Doctus cum libro /V\ Institut de physique nucleaire de Lyon (IN2P3 - France) // \\ Tel: (33/0) 472 431 968 AIM: YnCopin ICQ: 236931013 /( )\ http://snovae.in2p3.fr/ycopin/ ^`~'^ #!/usr/bin/env python import numpy as N import matplotlib.pyplot as P x = N.arange(5,dtype='d') # Position y = x / 2 w = x/3 # Width h = x/4 # Height a = x*10# PA [deg] xy = N.vstack((x,y)).T # (n,2) ax = P.subplot(1,1,1) # Using EllipseCollection: size is incorrect, and depends on aspect ratio coll = P.matplotlib.collections.EllipseCollection(widths=w, heights=h, angles=a, units='x', offsets=xy, transOffset=ax.transData, edgecolor='r', facecolor='r', alpha=0.3) ax.add_collection(coll) # Using plain list of Ellipse's: correct behavior ells = [ P.matplotlib.patches.Ellipse(xy=xyi, width=wi, height=hi, angle=ai, edgecolor='b', facecolor='b', alpha=0.3) for xyi,wi,hi,ai in zip(xy,w,h,a)] for ell in ells: ax.add_artist(ell) ax.autoscale_view() P.show() -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Possible workaround for memory leak using pylab.figure(), pylab.show() ?
Hi thanks for the answers, but I do not think it is applicable in this situation. In the application I have an event that triggered (e.g., a button is pressed) the opening of the window by pylab.figure() and then the application shows (via figure pylab.show()) it to the user. So, the user defines when the figure will be closed. So, if I use pylab.close(1) in the application, I cannot use pylab.show() afterwards in the code (because it will be nothing to show...) The only way I found to 'flush' the memory is via bind() based on the 'master' (e.g., master = Tkinter.Tk(), master.bind('Destroy', self.close_showed_figures()) but it is already late for the application because the memory leak is only of concern when 'master' does not destroyed. Kind regards, Tanja On Mon, Feb 1, 2010 at 3:33 PM, Bruno Santos bacmsan...@gmail.com wrote: Have you tried the pylab.close() this should force the flush of the memory. 2010/2/1 Tanja Gurzhiy tanja.gurz...@gmail.com Hi, I have already submitted this issue as a possible problem to Tracker, however there is no response till now http://sourceforge.net/tracker/?func=detailaid=2940967group_id=80706atid=560720. Probably, someone could help me with possible workaround for this problem. I use the pylab.figure in the other application where a user should close the figure manually. After the figure is closed, I would expect the memory goes back to the level it was before. However, it is not the case, I have noticed a memory leak when using pylab.figure(), pylab.show().If I try to let show figure via pylan.ion(), then pylab.figure() and pylab.iof(), I also see the memory leak. Below is simple example: pylab.ion() for i in range(10): pylab.figure() pylab.draw() val = cbook.report_memory(i) print i, val pylab.ioff() the same loop is used for show(): for i in range(10): pylab.figure() pylab.plot([1,3]) val = cbook.report_memory(i) print i, val pylab.show() I use the python version 2.5.1, the matplotlib version 0.99.0, OS: SunOs5 (Solaris), backend: TkAgg. Thanks in advance, Tanja -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Draw data not in rectangular shape
Scott Sinclair wrote: On 1 February 2010 11:34, Torsten Andre q...@takb.net wrote: I've got a a pylab 2D array which I plot using imshow() which just works fine. But part of the data within the array is not to be considered nor plotted. My problem is that I don't know how to plot the data again. Hi Torsten, Use NumPy masked arrays with imshow() [http://docs.scipy.org/doc/numpy/reference/maskedarray.html]. You can use the masked array just as you have been using your regular NumPy array, they are designed for this purpose and Matplotlib will not plot the masked portion of your data. The pylab interface actually imports numpy so your pylab array is really a NumPy ndarray object (try calling print type(your_pylab_array) to see this). Cheers, Scott -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users Hi Scott, thank you very much. MA is exactly what I was looking for. Works perfectly fine. Cheers, Torsten -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Size of ellipses in EllipseCollection
Yannick Copin wrote: Hi, I would like to plot lots of error ellipses on my plot. I thought I could use an EllipseCollection to do so, but I didn't manage to get the ellipse sizes, expressed in data units, right (see test script attached). When using a plain list of Ellipse's, everything looks fine: ells = [ P.matplotlib.patches.Ellipse(xy=xyi, width=wi, height=hi, angle=ai, edgecolor='b', facecolor='b', alpha=0.3) for xyi,wi,hi,ai in zip(xy,w,h,a)] for ell in ells: ax.add_artist(ell) But when using EllipseCollection (as explained in http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html), coll = P.matplotlib.collections.EllipseCollection(widths=w, heights=h, angles=a, units='x', offsets=xy, transOffset=ax.transData, edgecolor='r', facecolor='r', alpha=0.3) ax.add_collection(coll) the size of the ellipses (expressed in data units) appears incorrect, and depends furthermore of the aspect ratio of the figure (try pan/zoom or resize the interactive window). Maybe I am misunderstanding, but the EllipseCollection in the example is panning and zooming as I expect. The shapes and orientations are staying the same while the scale expands and contracts with the x-axis. The problem is that the option you are looking for does not exist yet. I am not sure yet whether what you need is identical to an option I added to quiver (from which I partially derived EllipseCollection). I suspect it is. Do you want width to scale with x and height to scale with y? And the angle to scale such that a 45-degree angle always corresponds to equal increments in x and in y, all in data units? I naively thought the two approaches should give the same result... Did I miss something in the way to use EllipseCollections? EllipseCollection is derived more from quiver than from Ellipse. Eric -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Axes3D rotation not working when embedded in backend
I would like to use Axes3D embedded in Wx. This works, but there is no mouse rotation. Clicking and dragging the mouse on the plot does not rotate the 3D axes like it does in the scatter3d_demo.py. I tried: WX, WXAgg, and TkAgg with similar results. Can this be fixed soon, or can someone point me to where I can try to fix it? I tested with the latest SVN tree on Linux and Windows. Thanks, -Ben Below is some sample code adapted from embedding_in_wx2.py, but with an Axes3D instead of the regular plot: #!/usr/bin/env python # adapted from example code embedding_in_wx2.py # Used to guarantee to use at least Wx2.8 import wxversion wxversion.ensureMinimal('2.8') import numpy as np import matplotlib # uncomment the following to use wx rather than wxagg #matplotlib.use('WX') #from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas # comment out the following to use wx rather than wxagg matplotlib.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure from mpl_toolkits.mplot3d import Axes3D import wx class CanvasFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self,None,-1, 'CanvasFrame',size=(550,350)) self.SetBackgroundColour(wx.NamedColor(WHITE)) self.figure = Figure() self.axes = Axes3D(self.figure) xs = np.random.rand(100) ys = np.random.rand(100) zs = np.random.rand(100) self.axes.scatter(xs, ys, zs) self.canvas = FigureCanvas(self, -1, self.figure) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit() self.add_toolbar() # comment this out for no toolbar def add_toolbar(self): self.toolbar = NavigationToolbar2Wx(self.canvas) self.toolbar.Realize() if wx.Platform == '__WXMAC__': # Mac platform (OSX 10.3, MacPython) does not seem to cope with # having a toolbar in a sizer. This work-around gets the buttons # back, but at the expense of having the toolbar at the top self.SetToolBar(self.toolbar) else: # On Windows platform, default window size is incorrect, so set # toolbar width to figure width. tw, th = self.toolbar.GetSizeTuple() fw, fh = self.canvas.GetSizeTuple() # By adding toolbar in sizer, we are able to put it at the bottom # of the frame - so appearance is closer to GTK version. # As noted above, doesn't work for Mac. self.toolbar.SetSize(wx.Size(fw, th)) self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) # update the axes menu on the toolbar self.toolbar.update() def OnPaint(self, event): self.canvas.draw() class App(wx.App): def OnInit(self): 'Create the main window and insert the custom frame' frame = CanvasFrame() frame.Show(True) return True app = App(0) app.MainLoop() #end code -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Label picker broken?
Current pick implementation explicitly checks if the event is inside the axes. So, you cannot pick artists outside the axes area. This seems more like an intended feature than a bug, but I may be wrong. And my guess is that this is to prevent picking invisible artists (as they are clipped). While others may have better advice, mine is to use button pressed event directly. lab = ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) def picklabel(artsits, mouseevent): for a in artsits: a.pick(mouseevent) from functools import partial b1 = fig.canvas.mpl_connect('button_press_event', partial(picklabel, [lab])) Regards, -JJ On Fri, Jan 29, 2010 at 12:06 PM, Ben Axelrod baxel...@coroware.com wrote: Picking text outside of the axes region seems to be broken in matplotlib 0.99.1 and in the latest SVN. This functionality used to work in version 0.98.3. The example code pick_event_demo.py demonstrates the issue. The ylabel in the red box is no longer pickable. Is there a clip_on or similar setting on the picker that needs to be set now? Below is a simplified version of pick_event_demo.py for reference. I also added some text to the plot to make sure that text inside the axes region was still pickable. Thanks, -Ben #!/usr/bin/env python # simplified example code: pick_event_demo.py from matplotlib.pyplot import figure, show from matplotlib.lines import Line2D from matplotlib.patches import Patch, Rectangle from matplotlib.text import Text from matplotlib.image import AxesImage import numpy as npy from numpy.random import rand fig = figure() ax1 = fig.add_subplot(111) ax1.set_title('click on points, rectangles or text', picker=True) ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) ax1.text(50, 0.5, pick me, picker=True) line, = ax1.plot(rand(100), 'o', picker=5) # 5 points tolerance def onpick1(event): if isinstance(event.artist, Line2D): thisline = event.artist xdata = thisline.get_xdata() ydata = thisline.get_ydata() ind = event.ind print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata, ind)) elif isinstance(event.artist, Rectangle): patch = event.artist print 'onpick1 patch:', patch.get_path() elif isinstance(event.artist, Text): text = event.artist print 'onpick1 text:', text.get_text() fig.canvas.mpl_connect('pick_event', onpick1) show() #end code *Ben Axelrod* Robotics Engineer (800) 641-2676 x737 www.coroware.com www.corobot.net -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users image002.gif-- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] AXES properties
Are you using the axes_grid toolkit? Standard matplotlib axis instance does not have major_ticklabels attribute, while axes_grid axis does. Please post a simple, but complete example that can be run and tested. Regards, -JJ On Sun, Jan 31, 2010 at 11:06 AM, kc106_2005-matplot...@yahoo.com wrote: BTW: I tried to use set_position to change the position of the axes label as suggested by previous posting. No effect. - Original Message Hello, I am creating a plot with multiple y-axis (up to 6) and twinx works pretty well. The problem is that there are too much wasted spaces used up by the axes. Since I have multiple axes, it cuts into the amount of space available for the plot area. I need to know how I can squeeze some spaces out of the standard axes. First thing I discovered was that I can rotate the tick labels to vertical by: plt.setp(ax.major_ticklabels, rotation=vertical) where ax is my y-axis. But then: (1) How to reduce the space between the tick and the axes label? First I tried to place the label on top but couldn't get that to work. Then I tried to change the position property of the axis label object and that have no effect. So, can somebody please tell me how I can do these 2 things? (2) How to avoid overlapping tick labels? With the way the standard x and y axis are drawn, after I do a vertical rotate of the y tick labels, the first y tick label overlaps with the last x tick label since they are both center aligned. Is there any way to change the alignment of only the first and last tick labels of an axes (while keeping the rest center aligned)? Thanks, -- John Henry -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to add text below the legend
See if the example below works. plot([1,2,3], label=test) a=legend() import matplotlib.offsetbox as offsetbox txt=offsetbox.TextArea(Test 2) box = a._legend_box box.get_children().append(txt) box.set_figure(box.figure) For more control of legend, see the link below. http://abitofpythonabitofastronomy.blogspot.com/2010/01/customized-legend.html Regards, -JJ On Sun, Jan 31, 2010 at 11:59 AM, Ernest Adrogué eadro...@gmx.net wrote: Hi, I would like to add some text relative to the legend, let's say below it, and I don't know how to get the legend coordinates so I can pass them to the text() method. Does anyone know how to do it? Alternatively, if there was a way to add text inside the legend itself, it would also do the trick. Thank you in advance. Ernest -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Label picker broken?
Thanks for the workaround. I got it to work for the labels and title, but not axes tick labels. This still seems like a regression bug to me. Especially since matplotlib's own example code clearly shows that picking labels, titles, and tick labels outside the axes region should be possible with the standard picker. If the current picker behavior is the desired behavior, then the example code should at least be updated to show the new way to pick objects outside the axes. Thanks again, -Ben From: Jae-Joon Lee [mailto:lee.j.j...@gmail.com] Sent: Monday, February 01, 2010 3:48 PM To: Ben Axelrod Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] Label picker broken? Current pick implementation explicitly checks if the event is inside the axes. So, you cannot pick artists outside the axes area. This seems more like an intended feature than a bug, but I may be wrong. And my guess is that this is to prevent picking invisible artists (as they are clipped). While others may have better advice, mine is to use button pressed event directly. lab = ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) def picklabel(artsits, mouseevent): for a in artsits: a.pick(mouseevent) from functools import partial b1 = fig.canvas.mpl_connect('button_press_event', partial(picklabel, [lab])) Regards, -JJ On Fri, Jan 29, 2010 at 12:06 PM, Ben Axelrod baxel...@coroware.commailto:baxel...@coroware.com wrote: Picking text outside of the axes region seems to be broken in matplotlib 0.99.1 and in the latest SVN. This functionality used to work in version 0.98.3. The example code pick_event_demo.py demonstrates the issue. The ylabel in the red box is no longer pickable. Is there a clip_on or similar setting on the picker that needs to be set now? Below is a simplified version of pick_event_demo.py for reference. I also added some text to the plot to make sure that text inside the axes region was still pickable. Thanks, -Ben #!/usr/bin/env python # simplified example code: pick_event_demo.py from matplotlib.pyplot import figure, show from matplotlib.lines import Line2D from matplotlib.patches import Patch, Rectangle from matplotlib.text import Text from matplotlib.image import AxesImage import numpy as npy from numpy.random import rand fig = figure() ax1 = fig.add_subplot(111) ax1.set_title('click on points, rectangles or text', picker=True) ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) ax1.text(50, 0.5, pick me, picker=True) line, = ax1.plot(rand(100), 'o', picker=5) # 5 points tolerance def onpick1(event): if isinstance(event.artist, Line2D): thisline = event.artist xdata = thisline.get_xdata() ydata = thisline.get_ydata() ind = event.ind print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata, ind)) elif isinstance(event.artist, Rectangle): patch = event.artist print 'onpick1 patch:', patch.get_path() elif isinstance(event.artist, Text): text = event.artist print 'onpick1 text:', text.get_text() fig.canvas.mpl_connect('pick_event', onpick1) show() #end code Ben Axelrod Robotics Engineer (800) 641-2676 x737 [cid:875170521@01022010-3682] www.coroware.comhttp://www.coroware.com/ www.corobot.nethttp://www.corobot.net/ -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.netmailto:Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users inline: image002.gif-- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to calculate relative positions between objects
Here is a slightly revised version of your script. It has a separate axes for labeling whose width is determined by the maximum width of the labels (using MaxExtent from axes_grid toolkit). Give it a try and see if it fits your needs. Regards, -JJ import numpy as np import matplotlib.pyplot as plt from scipy.stats import gamma from mpl_toolkits.axes_grid import make_axes_locatable fig = plt.figure(1, (10, 10)) ax1 = fig.add_subplot(1, 1, 1) labels = ('0-9', '10-19', '20-29', '30-39', '40-49', '50-59', '60-69', '70-79', '80-89', '90-99') pad = np.max([len(i) for i in labels]) * .15 divider = make_axes_locatable(ax1) from mpl_toolkits.axes_grid.axes_size import MaxExtent labeltexts = [] labelextent = MaxExtent(labeltexts, width) padsmall=0.1 label_axes = divider.new_horizontal(size=labelextent, pad=padsmall, sharey=ax1, frame_on=False) label_axes.xaxis.set_visible(False) label_axes.yaxis.set_visible(False) fig.add_axes(label_axes) ax2 = divider.new_horizontal(size=100%, pad=padsmall, sharey=ax1) fig.add_axes(ax2) N = 10 ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars x = [gamma.pdf(i, 1, scale=2) for i in range(N)] y = [gamma.pdf(i, 5, scale=1) for i in range(N)] ind = np.arange(N) ax1.barh(ind, x, align=center) ax2.barh(ind, y, align=center) for loc, spine in ax1.spines.iteritems(): if loc in ['left','top']: spine.set_color('none') # don't draw spine for loc, spine in ax2.spines.iteritems(): if loc in ['right','top']: spine.set_color('none') # don't draw spine ax1.set_title('Men') ax2.set_title('Women') ax1.set_ylim(-0.5, N-0.5) #ax2.set_ylim(0, N) # Name bars ax1.set_yticks(ind) ax1.xaxis.set_ticks_position('bottom') ax2.xaxis.set_ticks_position('bottom') ax1.yaxis.set_ticks_position('right') ax2.yaxis.set_ticks_position('left') for tl in ax1.get_yticklabels()+ax2.get_yticklabels(): tl.set_visible(False) for i, l in zip(ind, labels): l = label_axes.annotate($%s$%l, (0.5, i), ha=center, va=center) labeltexts.append(l) ax1.set_xlim(0.5, 0) ax2.set_xlim(0, 0.5) plt.show() On Sun, Jan 31, 2010 at 7:40 PM, Renato Alves rjal...@igc.gulbenkian.pt wrote: Hi everyone I've been going around matplotlib objects trying to find a way to pre-calculate positions depending on input. I'm trying to create a function that draws two barplots facing opposite directions. This is what I managed so far: ### import numpy as np import matplotlib.pyplot as plt from scipy.stats import gamma from mpl_toolkits.axes_grid import make_axes_locatable fig = plt.figure(1, (10, 10)) ax1 = fig.add_subplot(1, 1, 1) ax1.set_xlim(1,0) labels = ('0-9', '10-19', '20-29', '30-39', '40-49', '50-59', '60-69', '70-79', '80-89', '90-99') pad = np.max([len(i) for i in labels]) * .15 divider = make_axes_locatable(ax1) ax2 = divider.new_horizontal(size=100%, pad=pad, sharey=ax1) fig.add_axes(ax2) N = 10 ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars x = [gamma.pdf(i, 1, scale=2) for i in range(N)] y = [gamma.pdf(i, 5, scale=1) for i in range(N)] ind = np.arange(N) ax1.barh(ind, x) ax2.barh(ind, y) for loc, spine in ax1.spines.iteritems(): if loc in ['left','top']: spine.set_color('none') # don't draw spine for loc, spine in ax2.spines.iteritems(): if loc in ['right','top']: spine.set_color('none') # don't draw spine ax1.set_title('Men') ax2.set_title('Women') ax1.set_ylim(0, N) ax2.set_ylim(0, N) # Name bars ax1.set_yticks(ind + width) ax1.xaxis.set_ticks_position('bottom') ax2.xaxis.set_ticks_position('bottom') ax1.yaxis.set_ticks_position('right') ax2.yaxis.set_ticks_position('left') for tl in ax1.get_yticklabels(): tl.set_visible(False) ax2.set_yticklabels(labels, horizontalalignment='center' ) for i in ax2.get_yticklabels(): i.set_position((-(pad * .12) , 0)) plt.show() ### However I would like to generalize this function but he space between the two plots and the position of the labels is giving me a hard time. In particular, the lines: pad = np.max([len(i) for i in labels]) * .15 i.set_position((-(pad * .12) , 0)) include two values (.15 and .12) that are completely arbitrary and defined by trial and error for current labels. However with different labels: labels = ('-9000', '10-19', '20-29', '30-39', '40-49', '50-59', '60-69', '70-79', '80-89', '9-99000') the values are no longer valid and the final image is no longer properly aligned. I know my current approach is not the proper way but due to the complexity of matplotlib, my very superficial knowledge about it and the overwhelming documentation this was the closest I could get. In the end I would like to contribute the final result as something to be included in the gallery/examples section of the website as I'm positive
Re: [Matplotlib-users] Label picker broken?
On Mon, Feb 1, 2010 at 4:30 PM, Ben Axelrod baxel...@coroware.com wrote: This still seems like a regression bug to me. Especially since matplotlib's own example code clearly shows that picking labels, titles, and tick labels outside the axes region should be possible with the standard picker. If the current picker behavior is the desired behavior, then the example code should at least be updated to show the new way to pick objects outside the axes. I agree. Unfortunately, event handling is not my specialty, and given no response from other developers, I recommend you file a bug (and hope other developers fix this). Regards, -JJ -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Label picker broken?
On Mon, Feb 1, 2010 at 3:47 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote: I agree. Unfortunately, event handling is not my specialty, and given no response from other developers, I recommend you file a bug (and hope other developers fix this). I wrote the original functionality and example and do consider this a regression, so do file a bug report and I'll try and get it fixed. JDH -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Label picker broken?
On Mon, Feb 1, 2010 at 4:34 PM, John Hunter jdh2...@gmail.com wrote: On Mon, Feb 1, 2010 at 3:47 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote: I agree. Unfortunately, event handling is not my specialty, and given no response from other developers, I recommend you file a bug (and hope other developers fix this). I wrote the original functionality and example and do consider this a regression, so do file a bug report and I'll try and get it fixed. Here is the bug report and fix that caused the current regression http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg11806.html The solution I propose is to do the axes comparison test only when the mouseevent.inaxes is not None (which happens when you are outside the axes rectangle). Then you could pick artists associated with an axes that are outside the rectangle, and still not get confused between two different axes with the same coord system. Try svn r8106. JDH -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Label picker broken?
Works for me! Although I did not test with Jorges's original code which caused the regression. Do you still want me to file a bug report so the issue is tracked? Thanks, -Ben -Original Message- From: John Hunter [mailto:jdh2...@gmail.com] Sent: Monday, February 01, 2010 5:47 PM To: Jae-Joon Lee Cc: Ben Axelrod; matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] Label picker broken? Importance: Low On Mon, Feb 1, 2010 at 4:34 PM, John Hunter jdh2...@gmail.com wrote: On Mon, Feb 1, 2010 at 3:47 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote: I agree. Unfortunately, event handling is not my specialty, and given no response from other developers, I recommend you file a bug (and hope other developers fix this). I wrote the original functionality and example and do consider this a regression, so do file a bug report and I'll try and get it fixed. Here is the bug report and fix that caused the current regression http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg11806.html The solution I propose is to do the axes comparison test only when the mouseevent.inaxes is not None (which happens when you are outside the axes rectangle). Then you could pick artists associated with an axes that are outside the rectangle, and still not get confused between two different axes with the same coord system. Try svn r8106. JDH -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Is there a transparent color, for overlaying contouf regions?
Hello, (This is a different question for the same project that led me to file a bug about alpha blending in contour .) I want to overlay a number of exclusion regions in a 2D parameter scan. I generate each region with contourf in succession, like: contourf(x,y,unphys,(1),alpha=1,colors=('w','k')) contourf(x,y,excl,(1),alpha=0.5,colors=('w','m')) ... The problem as you might guess is that if I overlay many regions, the white level at each new region washes out the underlying non-white colors. Is there a transparent color I can use instead of white? Or, is there an alternative way to overlay regions that avoids this problem? Thank you again! Best, Sourav -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Findng the right args and kwargs
Hi all, One of the most persistent problems I have with matplotlib is finding out which kwargs and args are available for some commands. For instance, I am looking at manipulating axis ticks and labels in mplot3d, so I went to the mplot3d api page, and looked for useful commands and found: set_xlabel(xlabel, fontdict=None, **kwargs)¶ Set xlabel. set_xlim3d(*args, **kwargs)¶ Set 3D x limits. However, there is no information that I can find about args and kwargs that I can use to figure out how to make my changes. For the record, I want to be able to change the size of the font, the # and values of the tick marks, and to move the axis labels to one or the other end of the axis they are labelling. Cheers Michael -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Is there a transparent color, for overlaying contouf regions?
On Mon, 2010-02-01 at 15:23 -1000, Eric Firing wrote: Alternatively, and more simply, why make the transparent regions in the first place? cs = contourf(rand(10,10), [0.5, 0.7], colors=('b')) Here we specify a single pair of limits between which the color will be blue. Well, that's embarrassing -- if I had read the documentation more carefully, I would have realized that the levels spec V means different things for contour and contourf. Thank you again! :) Regards, Sourav -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] AXES properties
set_position does not work with axes_grid toolkits. Try something like ax.LABELPAD = 0 However, note that this (and set_rotation) may not work with mpl_toolkits in future release of matplotlib as there has been some significant changes. Regards, -JJ ps. please use reply to all, so that messages stay inside the list. On Mon, Feb 1, 2010 at 7:52 PM, Kim Cheung ecs1...@gmail.com wrote: Mr. Lee, Thanks for the reply. The position call works with the first example but not the second: # Example 1 import pylab data1=[1,2,3,4,5,6,7] data2=[8,9,10,11,12,13,14] dates=['01','02','03','04','05','06','07'] pylab.subplot(211) pylab.plot(data1, label='Score 2005') pylab.plot(data2, label='Num 2006') pylab.setp(pylab.gca(), xticklabels=[]) pylab.ylabel('Score 2') pylab.title('Historical Statistics') pylab.legend(loc='upper left') pylab.subplot(212) pylab.plot(data1, label='Score 06') pylab.plot(data2, label='Num 06') pylab.xticks(pylab.arange(7),dates) xlabels = pylab.gca().get_xticklabels() ylabels = pylab.gca().get_yticklabels() pylab.setp(xlabels, 'rotation', 90) xlab=pylab.xlabel('Player') pylab.setp(xlab, position=(0.2,0.1)) # === This line works pylab.ylabel('Score 1') pylab.legend(loc='upper left') pylab.show() But doesn't work in this example: # Example 2 from mpl_toolkits.axes_grid.parasite_axes import SubplotHost import matplotlib.pyplot as plt from matplotlib.ticker import MultipleLocator, FormatStrFormatter if 1: figprops = dict(figsize=(8., 8. / 1.618), dpi=128) # Figure properties adjustprops = dict(left=0.08, bottom=0.12, right=0.79, top=0.96, wspace=0.2, hspace=0.2) # Subplot properties fig = plt.figure(**figprops) fig.subplots_adjust(**adjustprops) # Tunes the subplot layout host = SubplotHost(fig, 111) p0, = host.plot([0, 1, 2], [0, 1, 2], label=Density) ax=host.axis[left] plt.setp(ax.label, visible=True, text=Density, size=12, color=p0.get_color()) plt.setp(ax.major_ticklabels, rotation=vertical) plt.setp(ax.label, position=(0.2,0.1)) # This line has no effect. fig.add_axes(host) host.set_xlim(0, 2) host.set_ylim(0, 2) host.legend() plt.draw() plt.show() Jae-Joon Lee wrote: Are you using the axes_grid toolkit? Standard matplotlib axis instance does not have major_ticklabels attribute, while axes_grid axis does. Please post a simple, but complete example that can be run and tested. Regards, -JJ On Sun, Jan 31, 2010 at 11:06 AM, kc106_2005-matplot...@yahoo.com wrote: BTW: I tried to use set_position to change the position of the axes label as suggested by previous posting. No effect. - Original Message Hello, I am creating a plot with multiple y-axis (up to 6) and twinx works pretty well. The problem is that there are too much wasted spaces used up by the axes. Since I have multiple axes, it cuts into the amount of space available for the plot area. I need to know how I can squeeze some spaces out of the standard axes. First thing I discovered was that I can rotate the tick labels to vertical by: plt.setp(ax.major_ticklabels, rotation=vertical) where ax is my y-axis. But then: (1) How to reduce the space between the tick and the axes label? First I tried to place the label on top but couldn't get that to work. Then I tried to change the position property of the axis label object and that have no effect. So, can somebody please tell me how I can do these 2 things? (2) How to avoid overlapping tick labels? With the way the standard x and y axis are drawn, after I do a vertical rotate of the y tick labels, the first y tick label overlaps with the last x tick label since they are both center aligned. Is there any way to change the alignment of only the first and last tick labels of an axes (while keeping the rest center aligned)? Thanks, -- John Henry -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Kim Cheung -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com