Wonder-twin power "Zoom in to rectangle" activated?

enter image description here

Is there a way for the Zoom Rectangle tool to automatically activate by default when a matplotlib shape is displayed?

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()
+5
source share
1 answer

This works for me:

plt.get_current_fig_manager().toolbar.zoom()
+4
source

All Articles