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()
This works for me:
plt.get_current_fig_manager().toolbar.zoom()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With