5

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 Answer 1

10

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

Sign up to request clarification or add additional context in comments.

4 Comments

My setup as a pyqt4 application is a little different than what you describe but you got me on the right track.
The solution I ended up with was:codeself.mpl_toolbar = NavigationToolbar(self.map_canvas, None) self.mpl_toolbar.pan()'code'
Thanks! It's frustrating when something so simple can take so long to find.
If you're using import matplotlib.pyplot as plt , use this one liner plt.get_current_fig_manager().toolbar.pan() to default to pan

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.