From: Jean-Michel P. <jea...@ir...> - 2004-09-02 08:34:29
|
ste...@cs... wrote: > Zooming is available via the widgets at the bottom of the plot menu by > default. Ok but I would like to activate zooming for users within the program. The purpose is to display all the figures with the zoom activated by default because in this (small) application users always have to zoom. JM. |
From: Jean-Michel P. <jea...@ir...> - 2004-09-06 08:35:05
|
ste...@cs... wrote: > You want the initial graph to come up already zoomed in, is that it? yes, that's exactly this! JM. |
From: Jean-Michel P. <jea...@ir...> - 2004-09-06 09:21:05
|
jdh...@ac... wrote: > Indeed. Unfortunately, in the current implementation, all the logic > is in the toolbar itself. On the dev list there was some discussion > in the last few weeks on how to modularize the toolbar base class code > (matplotlib.backend_bases.NavigationToolbar2), with an implementation > that factored out all of this code into independent pieces. This was > done to support a user customizable and extensible toolbar, but might > have wider application as this thread suggests, eg to support a > default navigation mode in the absence of any toolbar at all. > Unfortunately, I haven't had time to investigate this or include it as > a patch yet. Would it be possible to add some facilities to get a list of the method associated to each toolbar button in order to call the underlying function directly from within the program? (I'm not sure this very clear... The idea is to be able to perform some actions automatically while creating figures instead of waiting for mouse button clicks - e.g. the command 'grid(1)' displays grids and this feature could also be accessed from a toolbar button) > So in the current implementation, you have to call the 'pan' method of > the toolbar to set the pan/zoom functionality and the 'zoom' method to > activate zoom to rect. > > The following untested code should work across backends from the > matlab interface (using the API, you can access the toolbar instance > more directly) > > manager = get_current_fig_manager() > toolbar = manager.canvas.toolbar > toolbar.pan() # activate pan w/ left and zoom w/ right by default Ok, with TkAgg / matplotlib 0.62.4 I just had to use 'manager.toolbar' instead of 'manager.canvas.toolbar'. Obviously pan() is used to move the figure view and zoom() to let the user draw rectangles around the region to be zoomed. This is the last one which I needed: > manager = get_current_fig_manager() > manager.toolbar.zoom() (Thanks, I always knew this would be few code lines!) > I think your idea of adding a 'zoom on' function which can be called > from the matlab interface is a good one; any idea if there is a matlab > analog for activating zoom to rect? > Indeed 'zoom' activates zoom to rectangular region as toolbar.zoom() does. The only difference is that zoom in Matlab is able to toggle or to set the zoom state depending on the input args: zoom -> toggles the zoom zoom on -> turn it on zoom off -> turn it off So the previous code only mimics the first implementation. As I don't know how to get the zoom state, I cannot propose a full Matlab replacement to the 'zoom' function. Perhaps the modularized toolbar could introduce this feature for each button with a simple code like this: def myButtonCallBackFunc(state=-1): if state == -1: # toggle elif state == 0: # reset elif state == 1; # set else: #raise error Doing this each toolbar button would be easy to toggle or turn on/off from code and we could easily implement a matplotlib version of the Matlab 'zoom' function. JM. Philippe |
From: Stephen W. <ste...@cs...> - 2004-09-04 16:25:19
|
On Thu, 2004-09-02 at 01:33, Jean-Michel Philippe wrote: > ste...@cs... wrote: > > Zooming is available via the widgets at the bottom of the plot menu by > > default. >=20 > Ok but I would like to activate zooming for users within the program.=20 You want the initial graph to come up already zoomed in, is that it? --=20 Stephen Walton <ste...@cs...> Dept. of Physics & Astronomy, CSU Northridge |
From: Darren D. <dd...@co...> - 2004-09-04 16:51:38
|
Stephen Walton wrote: >On Thu, 2004-09-02 at 01:33, Jean-Michel Philippe wrote: > > >>ste...@cs... wrote: >> >> >>>Zooming is available via the widgets at the bottom of the plot menu by >>>default. >>> >>> >>Ok but I would like to activate zooming for users within the program. >> >> > >You want the initial graph to come up already zoomed in, is that it? > > In Matlab, you can create a plot, and then calling "zoom on" does the same thing as clicking the zoom button in MPL: it just gives zooming context to mouse clicks inside the axes. It would be helpful to know how to give such context to mouse clicks without having to include toolbar2 in a figure. Darren |
From: John H. <jdh...@ac...> - 2004-09-06 04:39:08
|
>>>>> "Darren" == Darren Dale <dd...@co...> writes: Darren> In Matlab, you can create a plot, and then calling "zoom Darren> on" does the same thing as clicking the zoom button in Darren> MPL: it just gives zooming context to mouse clicks inside Darren> the axes. It would be helpful to know how to give such Darren> context to mouse clicks without having to include toolbar2 Darren> in a figure. Indeed. Unfortunately, in the current implementation, all the logic is in the toolbar itself. On the dev list there was some discussion in the last few weeks on how to modularize the toolbar base class code (matplotlib.backend_bases.NavigationToolbar2), with an implementation that factored out all of this code into independent pieces. This was done to support a user customizable and extensible toolbar, but might have wider application as this thread suggests, eg to support a default navigation mode in the absence of any toolbar at all. Unfortunately, I haven't had time to investigate this or include it as a patch yet. So in the current implementation, you have to call the 'pan' method of the toolbar to set the pan/zoom functionality and the 'zoom' method to activate zoom to rect. The following untested code should work across backends from the matlab interface (using the API, you can access the toolbar instance more directly) manager = get_current_fig_manager() toolbar = manager.canvas.toolbar toolbar.pan() # activate pan w/ left and zoom w/ right by default Note that calling this function toggles the current state, as does the 'zoom' function. I think your idea of adding a 'zoom on' function which can be called from the matlab interface is a good one; any idea if there is a matlab analog for activating zoom to rect? Thanks, JDH |