wetvorti.blogg.se

Zoomify constrain pan
Zoomify constrain pan




OldMethod = getattr(toolbar._class_, methodname) If hasattr(self, 'postPressZoomHandler'):ĭef overrideToolbarZoom(fig, methodname, functransform, *args): # make sure all figures' toolbars of this class call a postPressZoomHandler() Simonb's approach worked but I had to tweak it for the press_zoom behavior, so that it keeps the press_zoom method a feature of the class, not the instance, but I added a hook to fixup the per-instance behavior. I don't think there's a really straightforward way to just use your own toolbar with the simple plotting interface. You could do it properly and make a subclass of the toolbar, but you have to then create instances of Figure, FigureCanvas and your NavigationToolbar and put them in a Tk app or something. _zoom(self,event)į_zoom=types.MethodType(press_zoom, ) You can monkeypatch the desired behaviour in: import types The NavigationToolbar2 class has the drag_zoom method which seems to be what's relevant here, but tracking down how that works is quickly complicated by the fact that the different backends all have their own versions (e.g. _projection(My_Axes)Īx = figure.add_subplot(111, projection="My_Axes")įor the zooming, you may have to look at the toolbar control itself.

zoomify constrain pan

_pan(self, button, 'x', x, y) # pretend key='x' The following will only allow x axis panning: import matplotlib

zoomify constrain pan

However the zooming doesn't seem to be defined in that class. In your case you can inherit from and change the drag_pan method to always act as though the 'x' key is being pressed. It is possible to use your own axes class.






Zoomify constrain pan