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 |