Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wonder-twin power "Zoom to rectangle" activate?

enter image description here

Is there a way to have the "Zoom to rectangle" tool automatically activated by default when a matplotlib figure is shown?

import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-300, 300)
y = x**2-7*x
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.plot(x, y)
# Add something here to activate the "Zoom to rectangle" tool?
plt.show()
like image 407
unutbu Avatar asked Nov 15 '11 23:11

unutbu


1 Answers

This works for me:

plt.get_current_fig_manager().toolbar.zoom()
like image 186
Sven Marnach Avatar answered Oct 22 '22 09:10

Sven Marnach