|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
pan/zoom axes problemHi,
I'm a newbie to matplotlib. I'm embedding matplotlib (0,98.5.3) in a pyqt application. I'm using the qt4 backend and its navigation toolbar. I wish to execute a certain function every time the view interval of a figure is changed interactively (i.e. using the zoom rectangle or the axes pan/zoom button of the navigation toolbar). I'm interested in changes due to axes zoom and rectangle zoom but not in changes due axes pan. The only way I know for detecting this changes is 'x/ylim_changed' events. Unfortunately I don't know how to distinguish if the event is caused by a rectangle zoom, an axes zoom or an axes pan. I've read the events section of the documentation and searched the archives for a solution with no luck. Could somebody help me to solve this problem? Thanks in advance. Vicent PS: -- Share what you know, learn what you don't. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
|
Re: pan/zoom axes problemHi Vicent,
I think the following example may help you, althogh their might be a better way: ############################## import matplotlib.pyplot as plt def callback(ax): """ prints mode of toolbar after limits changed e.g. mode : >zoom rect< mode : >pan/zoom< """ print " mode : >%s<" % (plt.get_current_fig_manager().toolbar.mode) ax = plt.gca() ax.callbacks.connect('xlim_changed', callback) ax.callbacks.connect('ylim_changed', callback) plt.show() ###################################### kind regards Matthias On Thursday 03 September 2009 14:07:06 Vicent Mas wrote: > Hi, > > I'm a newbie to matplotlib. I'm embedding matplotlib (0,98.5.3) in a > pyqt application. I'm using the qt4 backend and its navigation > toolbar. > > I wish to execute a certain function every time the view interval of > a figure is changed interactively (i.e. using the zoom rectangle or > the > axes pan/zoom button of the navigation toolbar). I'm interested in > changes due to axes zoom and rectangle zoom but not in changes due > axes pan. The only way I know for detecting this changes is > 'x/ylim_changed' events. Unfortunately I don't know how to distinguish > if the > event is caused by a rectangle zoom, an axes zoom or an axes pan. > I've read the events section of the documentation and searched the > archives for a solution with no luck. Could somebody help me to > solve this problem? > > Thanks in advance. > > Vicent > > PS: ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
|
Re: pan/zoom axes problemHi Matthias,
2009/9/3 Matthias Michler <MatthiasMichler@...>: > Hi Vicent, > > I think the following example may help you, althogh their might be a better > way: > thanks for your answer. It really helps. I didn't know about the mode attribute of navigation toolbars. Inspecting the NavigationToolbar2QTAgg class interactively with an IPython shell doesn't show such attribute for this class. Maybe it is created dynamically when the pan/zoom button is clicked? Now I still have to find out how to distinguish axes pan from axes zoom cases. I suppose I can use 'button_press_event' canvas events and use the button attribute of these events for knowing if the user is doing a pan or a zoom: pan/zoom mode + left button --> user is panning axes, pan/zoom mode + right button --> user is zooming axes. Right? Anyway, thanks again for your help. -- Share what you know, learn what you don't. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
|
Re: pan/zoom axes problemHi Vicent,
On Thursday 03 September 2009 18:14:37 Vicent Mas wrote: > Hi Matthias, > > 2009/9/3 Matthias Michler <MatthiasMichler@...>: > > Hi Vicent, > > > > I think the following example may help you, althogh their might be a > > better way: > > thanks for your answer. It really helps. I didn't know about the mode > attribute of navigation toolbars. Inspecting the > NavigationToolbar2QTAgg class interactively with an IPython shell > doesn't show such attribute for this class. Maybe it is created > dynamically when the pan/zoom button is clicked? I think: The attribute 'mode' is added during the initialisation of the toolbar (actually it is set during the initalisation of backend_qt.NavigationToolbar2QT and therefore you can see it directly as attribute of the abstract class NavigationToolbar2QTAgg, which inherits from backend_qt.NavigationToolbar2QT). Therefore the following works: import matplotlib matplotlib.use("QTAgg") import matplotlib.pyplot as plt print "initialised toolbar : ", plt.get_current_fig_manager().toolbar print " >%s<" % (plt.get_current_fig_manager().toolbar.mode) > Now I still have to find out how to distinguish axes pan from axes > zoom cases. I suppose I can use 'button_press_event' canvas events and > use the button attribute of these events for knowing if the user is > doing a pan or a zoom: pan/zoom mode + left button --> user is panning > axes, pan/zoom mode + right button --> user is zooming axes. Right? I send you again my previous example with some additional lines. In my opinion you can use either 'button_press_event' or axes-callbacks to achieve what you want, but maybe I'm missing something. regards Matthias import matplotlib.pyplot as plt def callback(ax): """ prints mode of toolbar after limits changed e.g. mode : >zoom rect< mode : >pan/zoom< """ print " mode : >%s<" % (plt.get_current_fig_manager().toolbar.mode) if plt.get_current_fig_manager().toolbar.mode == 'zoom rect': print "We are in zoom with Rectangle - mode" elif plt.get_current_fig_manager().toolbar.mode == 'pan/zoom': print "We are in pan/zoom - mode" def fct(event): """ print zoom-mode after 'button_press_event' """ if plt.get_current_fig_manager().toolbar.mode == 'zoom rect': print "We are in zoom with Rectangle - mode" elif plt.get_current_fig_manager().toolbar.mode == 'pan/zoom': print "We are in pan/zoom - mode" ax = plt.gca() ##ax.callbacks.connect('xlim_changed', callback) ##ax.callbacks.connect('ylim_changed', callback) plt.connect("button_press_event", fct) plt.show() ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
|
Re: pan/zoom axes problemHi Matthias ,
thanks a lot for your explanations. They were very useful. Vicent -- Share what you know, learn what you don't. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
|
Re: pan/zoom axes problemDear Vicent,
I'm struggling with embedding a navigation toolbar in a QT4 application with matplotlib canvas. Could you please send me an example code of how I add the navigation toolbar in the first place? As you notice, I'm a real newbe! Thank you very much, Thom
|
|
|
Re: pan/zoom axes problem> Dear Vicent,
Hi,
> > I'm struggling with embedding a navigation toolbar in a QT4 application > with matplotlib canvas. Could you please send me an example code of how I > add the navigation toolbar in the first place? > > As you notice, I'm a real newbe! > > Thank you very much, > > Thom > > Vicent Mas-2 wrote: > > Hi Matthias , > > > > thanks a lot for your explanations. They were very useful. > > > > Vicent > you can start here (it is what I did :-): http://eli.thegreenplace.net/2009/05/23/more-pyqt-plotting-demos/ Hope it helps. Vicent :: Share what you know, learn what you don't ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Matplotlib-users mailing list Matplotlib-users@... https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
| Free embeddable forum powered by Nabble | Forum Help |