How to programmatically select pan/zoom in pyqt/ma

2019-04-09 09:39发布

问题:

I have a pyqt4 matplotlib application and I would like the figure to start out (default) to the pan zoom mode when the application opens. I can't find any example or clue from the documentation on how to do this programmatically.

Also along this same line how would I enable the shortcut keys in my application (http://matplotlib.sourceforge.net/users/navigation_toolbar.html)

Thanks for any suggestions.

Colin

回答1:

I had a similar issue and in my case I solved it by using toolbar.zoom():

import pylab

plt.Figure()
thismanager = get_current_fig_manager()
thismanager.toolbar.zoom()

In that case the figure will appear with the zoom tool already selected