[Matplotlib-users] "Pick"-ing axis labels or tick labels
Hi All, I'm trying to respond to double-click events on axis labels and tick labels. I'm using the wxAgg backend, and matplotlib directly, not through pylab. The matplotlib panels are wrapped into a bigger program. Based on an thread between Andrea Gavana and Chris Barker back in Feb 06, I hacked a double-click event into backend_bases.py and backend_wx.py. This seems to work as expected; I can capture the double click events without any problem. Now for capturing pick events, the built-in pick function seems to rely on the selection being "inaxes" so I borrowed heavily from the object_picker.py demo to capture selecting the tick labels or the axis labels. My concern is that I'm reinventing the wheel. Being able to capture picks of the various labels seems like a natural thing to want to do (e.g. for modifying font properties, display format, etc). Is there an easier (erm, and better!) way to accomplish what I've done? Thanks, Anthony. -- Anthony Floyd, PhD Convergent Manufacturing Technologies Inc. 6190 Agronomy Rd, Suite 403 Vancouver BC V6T 1Z3 CANADA Email: [EMAIL PROTECTED] | Tel: 604-822-9682 WWW: http://www.convergent.ca| Fax: 604-822-9659 CMT is hiring: See http://www.convergent.ca for details - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] object canvas
Hi Paul, > I would like to be able to use matplotlib as an object canvas, where > items on the canvas receive mouse events (enter, leave, press, > release) and the registered callback is invoked. I do this rather extensively with the wxAgg backend and wxPython widgets. Which backend/platform are you targeting? > For example, I want to be able to highlight the line associated with > the legend entry as I mouse over the legend, and conversely highlight > the legend entry associated with the line as I mouse over the line. > I will also want to do operations such right clicking on the axis to > modify axis properties such as linear/log scale, and click on legend > entries to toggle lines on and off. These things are all do-able, but my experience has been that I've needed to modify backend_bases.py, backend_wx.py, and backend_wxagg.py in order to implement some of my own mouse events (double click, context click). Further, I capture some wx events and pass them on to my plotting canvas without using the mpl event system. As long as you translate the pick locations properly (mpl uses lower left as x=0,y=0, where wx uses upper left) it's not too difficult. > >From looking at the pick_event_demo in examples, I have a lot of work > ahead of me. Is this the state of the art? Yes. Prior to 0.90 there was no pick_event at all, and doing picking and hit testing was much more complicated. My own code existed pre 0.90 and so I have my own pick routines which work well but might be improved by updating them to the new picker features. The problem is, of course, that they work well enough and I've got other fish to fry. There are quite a number of more experienced and more qualified people on this list that also do the things you're talking about, but as far as I know there's no "one way". Good luck, Anthony. -- Anthony Floyd, PhD Convergent Manufacturing Technologies Inc. 6190 Agronomy Rd, Suite 403 Vancouver BC V6T 1Z3 CANADA Email: [EMAIL PROTECTED] | Tel: 604-822-9682 WWW: http://www.convergent.ca| Fax: 604-822-9659 CMT is hiring: See http://www.convergent.ca for details - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Properly aligned tick labels on the inside
Hi All, I'm trying to plot tick labels on the inside (ie data side) of a typical x-y plot. My setup is Python 2.5.1, matplotlib 0.90.0 on WinXP. I've been able to accomplish this by adjusting the padding of the individual ticks, but it doesn't quite accomplish what I want. For example, imagine a typical x-y plot, except that the tick labels are on the right-hand side (by setting axes.yaxis.tick_right()). Adjusting the padding of the ticks by doing: for tick in axes.yaxis.get_major_ticks(): tick.set_pad(-25) I'm able to get the numbers to appear about where I want. The problem is that these numbers are left aligned. So, it works fine for small numbers, but for large numbers, or when my tick formatter switches over to using scientific notation the numbers will overlap the axis. If my labels are on the inside of the right-hand side, I want them to be right-aligned and grow left towards the centre of the plot. I thought about doing it by setting tick_left() and then using a (large) computed pad, but then the tick lines are on the wrong side. So, my question is: can I get right-aligned tick labels on the right-side of a plot? How? I suspect I can do this by using axis.set_offset_position('...'), but I've been unable to get that to do anything in my tests using pylab. I can post code if it'll be helpful. Thanks, Anthony. -- Anthony Floyd, PhD Convergent Manufacturing Technologies Inc. 6190 Agronomy Rd, Suite 403 Vancouver BC V6T 1Z3 CANADA Email: [EMAIL PROTECTED] | Tel: 604-822-9682 WWW: http://www.convergent.ca| Fax: 604-822-9659 CMT is hiring: See http://www.convergent.ca for details - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Properly aligned tick labels on the inside
For the archives (and further proof that programming done during the witching hour between 4pm and 5pm should be avoided at all costs): The solution is easy. for tick in axes.yaxis.get_major_ticks(): tick.set_pad(-25) tick.label2.set_horizontalalignment('right') A> > -Original Message- > From: Anthony M. Floyd > Sent: July 12, 2007 4:37 PM > To: matplotlib-users@lists.sourceforge.net > Subject: [Matplotlib-users] Properly aligned tick labels on the inside > > Hi All, > > I'm trying to plot tick labels on the inside (ie data side) > of a typical x-y plot. My setup is Python 2.5.1, matplotlib > 0.90.0 on WinXP. > > I've been able to accomplish this by adjusting the padding of > the individual ticks, but it doesn't quite accomplish what I want. > > For example, imagine a typical x-y plot, except that the tick > labels are on the right-hand side (by setting > axes.yaxis.tick_right()). Adjusting the padding of the ticks > by doing: > > for tick in axes.yaxis.get_major_ticks(): > tick.set_pad(-25) > > I'm able to get the numbers to appear about where I want. > The problem is that these numbers are left aligned. So, it > works fine for small numbers, but for large numbers, or when > my tick formatter switches over to using scientific notation > the numbers will overlap the axis. If my labels are on the > inside of the right-hand side, I want them to be > right-aligned and grow left towards the centre of the plot. > > I thought about doing it by setting tick_left() and then > using a (large) computed pad, but then the tick lines are on > the wrong side. > > So, my question is: can I get right-aligned tick labels on > the right-side of a plot? How? > > I suspect I can do this by using > axis.set_offset_position('...'), but I've been unable to get > that to do anything in my tests using pylab. > > I can post code if it'll be helpful. > > Thanks, > Anthony. > > -- > Anthony Floyd, PhD > Convergent Manufacturing Technologies Inc. > 6190 Agronomy Rd, Suite 403 > Vancouver BC V6T 1Z3 > CANADA > > Email: [EMAIL PROTECTED] | Tel: 604-822-9682 > WWW: http://www.convergent.ca| Fax: 604-822-9659 > > CMT is hiring: See http://www.convergent.ca for details > > > > -- > --- > This SF.net email is sponsored by DB2 Express Download DB2 > Express C - the FREE version of DB2 express and take control > of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Reposition a Legend
Hi Anthony, > legend to be at the same height as the top of the axis. How > do I go about moving the legend once I've created it? myLegend._loc=(x,y) myFigure.draw() There doesn't seem to be a .moveLegend() or equivalent method, so I always update the semi-private ._loc and on redraw. After the draw, the legend appears where you want it (in 0..1 figure coords, not data coords). HTH, Anthony. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] problem with set in current svn HEAD
Hi! > 0x9c5a8ac>] >>> set(gca(), xticklabels=[]) Traceback (most > recent call last): > File "", line 1, in > TypeError: set() does not take keyword arguments > > Can somebody help me understand what goes wrong here? Python (since the docs were written) now has a built-in type called 'set'. This caused a namespace conflict with pylab's "set" command, so the pylab "set" command became "setp" for "set property". So, change the line to: >>> setp(gca(), xticklabels=[]) Cheers, A> - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Line collections vs a collection of lines
I'm trying to figure out the best way to handle the following situation: I have a wxApp that embeds a matplotlib figure in a panel. I use custom code to control adding and removing series from the axes in this figure, with some pretty fine grained control on when things get drawn, zoomed, etc. To be clear, I'm not using pylab here, I'm coding directly into matplotlib. Anyhow, I now have the case where I want to be plotting a modest number of series (say 100) with a reasonably large density (say >1000 pts). These series will all have the same or similar styles (thickness, colour, etc) and will definitely have the same length. In context of my current app, I could achieve this simply by calling my .addSeries routine multiple times. Or, I could use a Line Collection to handle them en masse. The thing is, after taking a quick read through of the source code, I'm not certain that I'm gaining anything by using a line collection in this case. I did a quick comparison using the line_collection.py example, and even using pylab there didn't seem to be any performance hit to doing: lines = [zip(x,y) for y in ys] for series in x: plot(lines[series]) Instead of using: line_segments = ... ax.add_collection(line_segments) Can anyone give me advice if I should code targeting collections or to just use my current single-series code? Thanks, Anthony. -- Anthony Floyd, PhD Convergent Manufacturing Technologies Inc. 6190 Agronomy Rd, Suite 403 Vancouver BC V6T 1Z3 CANADA Email: [EMAIL PROTECTED] | Tel: 604-822-9682 WWW: http://www.convergent.ca| Fax: 604-822-9659 CMT is hiring: See http://www.convergent.ca for details - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Line collections vs a collection of lines
> -Original Message- > From: Eric Firing [mailto:[EMAIL PROTECTED] [snip] > It probably comes down to program simplicity and readability, > not speed, in your case. > > Eric Hi Eric, Thanks for this. That's essentially the decision I had reached, but I was also wondering if I'd missed something significant. I think I will code it up as-is right now, and if the routine is unacceptably slow re-examine it with an eye to shifting over to using line-collections. In the same vein, if I need to refactor, is there any benefit to treating single series as a collection with only one segment? I would rather treat single series and multiple series in the same manner -- either plotting single series and multiple single-series or plotting single-series collections and multiple-series collections. That is, I'd rather not have to treat plotting a single series in one manner and multiple series in another. Thanks, Anthony. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Line collections vs a collection of lines
[snip] > Are you aware that the plot method can plot the columns of > 2-D arrays? > Any kwargs apply to all the lines. When plot does this, it > makes a list of lines, not a line collection, so it is > similar to looping over a set of single plot commands. There > is no particular speed advantage, but it is nice and concise, > if it yields what you actually want. Interesting! No, I wasn't aware. I'll need to think a bit if that fits better into the framework we have here. Thanks for the input. Anthony. - This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users