Re: [matplotlib-devel] auto-rotating text and plotyy
Hi, Sorry I didn't respond to this immediately - I have had my mind on other things. plotyy is basically a wrapper around twinx that provides a bit of extra/built-in functionality. The idea is that you have two curves with similar x values, but different y that you want to plot together. It plots them both using twinx, but to help with visualisation, it changes the color of each curve and associated axis so that they are easy to distinguish (e.g., left blue, right green). This is also similar to a matlab function of the same name, so it helps us matlab converts out. An example of using this function might be: x = linspace(0,pi,20) y = sin(x) x2 = linspace(0.1,pi-0.1,20) y2 = cos(x2) axs,h1,h2=plotyy(x,y,x2,y2) axs is a list with [ax1,ax2]. As is evident from the code itself, there isn't too much beyond what twinx already does, but this code aids matlab compatibility and also the recursive handle property change is useful. But this recursive code could be extricated to provide a general setp_recursive function that would change a property on an object and all its children (that have that property) if that is of interest. Cheers, David On Fri, 2008-07-25 at 15:00 -0400, Ryan May wrote: > David Kaplan wrote: > > The second patch is to pyplot.py to create a plotyy function. This is > > like a matlab function of the same name that puts two curves with > > different y ranges on the same x axis. It basically wraps the > > two_scales.py demo functionality with a bit of extra stuff. I had to > > use a real hack to change the colors of the y axes. Perhaps someone can > > think of a better way or perhaps this sub-function should be moved out > > of plotyy so it can be reused. Also, I couldn't find a way to color the > > actual y-axis - i.e. the vertical line that is the y-axis. Is there an > > easy way to do this? > > Do you have an example of how to use this (or at least what the results > look like)? I'm having trouble seeing how this differs from twinx. > > Ryan > -- ** David M. Kaplan Charge de Recherche 1 Institut de Recherche pour le Developpement Centre de Recherche Halieutique Mediterraneenne et Tropicale av. Jean Monnet B.P. 171 34203 Sete cedex France Phone: +33 (0)4 99 57 32 27 Fax: +33 (0)4 99 57 32 95 http://www.ur097.ird.fr/team/dkaplan/index.html ** - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] Bug2008303
[ 2008303 ] AttributeError: Unknown property histtype I think this bug can be closed. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] AttributeError: 'module' object has no attribute 'CallLater'
On Tue, 29 Jul 2008 12:10:09 -0400 Paul Kienzle <[EMAIL PROTECTED]> wrote: > On Tue, Jul 29, 2008 at 05:46:59PM +0200, Nils Wagner >wrote: >> On Mon, 28 Jul 2008 15:32:38 -0400 >> >> WxPython experts: what version do we require? If it >>is >> >>earlier than >> >> 2.8, then it appears we badly need a testing >>procedure >> >>to ensure >> >> compatibility. (A testing procedure for python >>version >> >>compatibility >> >> would be nice, also--has anyone looked into what it >> >>would take to set up >> >> and run a buildbot?) > > Rather than cycling through the mailing list for each > individual problem, can you please put together a patch > that works on wx-2.6? > > Preferably program to the 2.8 interface so that we don't > build up too much cruft. For example, >IsVisible->IsShownOnScreen > can be handled in __init__ with (untested!): > >if not hasattr(self,'IsShownOnScreen'): > self.IsShownOnScreen = self.IsVisible > > I would like to test the changes on 2.8, but I'm gone > July 31 to after Scipy. > > - Paul Hi Paul, Thank you for your prompt reply. Where should I add the lines if not hasattr(self,'IsShownOnScreen'): self.IsShownOnScreen = self.IsVisible I assume the corresponding file is in the directory matplotlib/lib/matplotlib/backends Is that correct ? I will try it asap. Thanks in advance Nils - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] AttributeError: 'module' object has no attribute 'CallLater'
On Mon, Jul 28, 2008 at 2:32 PM, Paul Kienzle <[EMAIL PROTECTED]> wrote: > Clearly I'm developing on 2.8, otherwise I wouldn't be introducing > so many issues for older versions. What version do people want > supported? For wxagg, we would like to support 2.6.3.2.2 and later (if it is not too much work) since this is the version in lenny testing. I think they've had a little trouble For wx native rendering, we must use 2.8 or later (if we are going to support this at all). So if you could add the IsVisible compatibility layer to wxagg, that would be great., this would be ideal JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] Bug2008303
On Tue, Jul 29, 2008 at 10:20 AM, Manuel Metz <[EMAIL PROTECTED]> wrote: > [ 2008303 ] AttributeError: Unknown property histtype > > I think this bug can be closed. OK, do you want to take care of it? - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] AttributeError: 'module' object has no attribute 'CallLater'
On Tue, Jul 29, 2008 at 11:19 AM, Nils Wagner <[EMAIL PROTECTED]> wrote: > Is that correct ? > > I will try it asap. > > Thanks in advance OK, I just added a compatibility method for isShownOnScreen. Can you give svn another test drive with your wx version, Nils? Thanks, JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] AttributeError: 'module' object has no attribute 'CallLater'
On Tue, 29 Jul 2008 13:01:04 -0500 "John Hunter" <[EMAIL PROTECTED]> wrote: > On Tue, Jul 29, 2008 at 11:19 AM, Nils Wagner > <[EMAIL PROTECTED]> wrote: > >> Is that correct ? >> >> I will try it asap. >> >> Thanks in advance > > OK, I just added a compatibility method for >isShownOnScreen. Can you > give svn another test drive with your wx version, Nils? > > Thanks, > JDH Hi John, My wxpython version (2.5.3.1) seems to be outdated. Anyway, is there any workaround ? File "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", line 2237, in spy b = ishold() File "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", line 466, in ishold return gca().ishold() File "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", line 566, in gca ax = gcf().gca(**kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", line 270, in gcf return figure() File "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", line 247, in figure FigureClass=FigureClass, File "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py", line 125, in new_figure_manager frame = FigureFrameWxAgg(num, fig) File "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wx.py", line 1346, in __init__ self.canvas = self.get_canvas(fig) File "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py", line 32, in get_canvas return FigureCanvasWxAgg(self, -1, fig) File "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wx.py", line 701, in __init__ self.IsShownOnScreen = self.IsVisible AttributeError: 'FigureCanvasWxAgg' object has no attribute 'IsVisible' Nils - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] AttributeError: 'module' object has no attribute 'CallLater'
On Tue, Jul 29, 2008 at 08:39:10PM +0200, Nils Wagner wrote: > On Tue, 29 Jul 2008 13:01:04 -0500 > "John Hunter" <[EMAIL PROTECTED]> wrote: > > On Tue, Jul 29, 2008 at 11:19 AM, Nils Wagner > > <[EMAIL PROTECTED]> wrote: > > > >> Is that correct ? > >> > >> I will try it asap. > >> > >> Thanks in advance > > > > OK, I just added a compatibility method for > >isShownOnScreen. Can you > > give svn another test drive with your wx version, Nils? > > > > Thanks, > > JDH > > Hi John, > > My wxpython version (2.5.3.1) seems to be outdated. > > Anyway, is there any workaround ? > > >File > "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", > line 2237, in spy > b = ishold() >File > "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", > line 466, in ishold > return gca().ishold() >File > "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", > line 566, in gca > ax = gcf().gca(**kwargs) >File > "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", > line 270, in gcf > return figure() >File > "/usr/lib/python2.4/site-packages/matplotlib/pyplot.py", > line 247, in figure > FigureClass=FigureClass, >File > "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py", > line 125, in new_figure_manager > frame = FigureFrameWxAgg(num, fig) >File > "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wx.py", > line 1346, in __init__ > self.canvas = self.get_canvas(fig) >File > "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py", > line 32, in get_canvas > return FigureCanvasWxAgg(self, -1, fig) >File > "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_wx.py", > line 701, in __init__ > self.IsShownOnScreen = self.IsVisible > AttributeError: 'FigureCanvasWxAgg' object has no > attribute 'IsVisible' Okay, how about if not hasattr(self,'IsVisible'): self.IsVisible = lambda self: True in __init__ That way it will always think it is visible. - Paul - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] AttributeError: 'module' object has no attribute 'CallLater'
On Tue, Jul 29, 2008 at 4:38 PM, Paul Kienzle <[EMAIL PROTECTED]> wrote: > Okay, how about >if not hasattr(self,'IsVisible'): >self.IsVisible = lambda self: True > in __init__ > > That way it will always think it is visible. OK, Nils, I committed a minor variant of that in r5926. Test again... JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] Alternate lasso: click to form polygon
I wanted something more precise (and easier on the carpal tunnel) than the included Lasso widget. Inspired by the existing Lasso, I forked out an alternate approach that creates a polygon with mouse clicks and returns a list of vertices to a callback function. See the attached for a demo. It's been tested with WxAgg running off recent svn. I'm using idle_event, which isn't mentioned in the docs for the released version. If there's interest, I'll put together a patch to add this to widgets.py. Thanks, Eric B from matplotlib.lines import Line2D from matplotlib.widgets import Widget class PolyLasso(Widget): """ A lasso widget that allows the user to define a lasso region by clicking to form a polygon. """ def __init__(self, ax, callback=None, line_to_next=True, useblit=True): """ Create a new lasso. *ax* is the axis on which to draw *callback* is a function that will be called with arguments (*ax*, *line*, *verts*). *verts* is a list of (x,y) pairs that define the polygon, with the first and last entries equal. *line_to_next* controls whether or not a line is drawn to the current cursor position as the polygon is created *useblit* = *True* is the only thorougly tested option. """ self.axes = ax self.figure = ax.figure self.canvas = self.figure.canvas self.useblit = useblit self.line_to_next = line_to_next if useblit: self.background = self.canvas.copy_from_bbox(self.axes.bbox) self.verts = [] self.line = None self.callback = callback self.cids = [] self.cids.append(self.canvas.mpl_connect('button_release_event', self.onrelease)) self.cids.append(self.canvas.mpl_connect('motion_notify_event', self.onmove)) self.cids.append(self.canvas.mpl_connect('draw_event', self.ondraw)) def ondraw(self, event): """ draw_event callback, to take care of some blit artifacts """ self.background = self.canvas.copy_from_bbox(self.axes.bbox) if self.line: self.axes.draw_artist(self.line) self.canvas.blit(self.axes.bbox) def do_callback(self, event): """ idle_event callback after polygon is finalized. """ # Clear out callbacks. for cid in self.cids: self.canvas.mpl_disconnect(cid) self.callback(self.axes, self.line, self.verts) self.cleanup() def cleanup(self): """ Remove the lasso line. """ # Clear out callbacks for cid in self.cids: self.canvas.mpl_disconnect(cid) self.axes.lines.remove(self.line) self.canvas.draw() def finalize(self): """ Called when user makes the final right click """ # all done with callbacks pertaining to adding verts to the polygon for cid in self.cids: self.canvas.mpl_disconnect(cid) self.cids = [] # Greater than three verts, since a triangle # has a duplicate point to close the poly. if len(self.verts)>3: # Matplotlib will not draw the closed polygon until we step completely # out of this routine. It is desirable to see the closed polygon on screen # in the event that *callback* takes a long time. So, delay callback until # we get an idle event, which will signal that the closed polygon has also # been drawn. self.cids.append(self.canvas.mpl_connect('idle_event', self.do_callback)) else: print 'Need at least three vertices to make a polygon' self.cleanup() def draw_update(self): """ Adjust the polygon line, and blit it to the screen """ self.line.set_data(zip(*self.verts)) if self.useblit: self.canvas.restore_region(self.background) self.axes.draw_artist(self.line) self.canvas.blit(self.axes.bbox) else: self.canvas.draw_idle() def onmove(self, event): """ Update the next vertex position """ if self.line == None: return self.verts[-1] = ((event.xdata, event.ydata)) if self.line_to_next: self.draw_update() def onrelease(self, event): """ User clicked the mouse. Add a vertex or finalize depending on mouse button. """ if self.verts is None: return if event.inaxes != self.axes: return if event.button == 3: # Right click - close the polygon # Set the dummy point to the first point self.verts[-1] = self.verts[0] self.draw_update() self.finalize() return # The rest pertains to left click only if event.button != 1: return if sel
Re: [matplotlib-devel] Alternate lasso: click to form polygon
Eric Bruning wrote: > I wanted something more precise (and easier on the carpal tunnel) than > the included Lasso widget. Inspired by the existing Lasso, I forked > out an alternate approach that creates a polygon with mouse clicks and > returns a list of vertices to a callback function. > > See the attached for a demo. It's been tested with WxAgg running off > recent svn. I'm using idle_event, which isn't mentioned in the docs > for the released version. > > If there's interest, I'll put together a patch to add this to widgets.py. Yes, there is interest--we should have this functionality if it can work on all interactive backends. I gave it a quick try with gtk backend. The polygon is drawn based on clicks, but nothing gets printed. Is this expected? Eric > > Thanks, > Eric B > > > > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > > > ___ > Matplotlib-devel mailing list > Matplotlib-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel