Wonder-twin power“Zoom to rectangle”激活?

时间:2011-11-15 23:12:04

标签: python matplotlib

enter image description here

当显示matplotlib图时,有没有办法让默认情况下自动激活“缩放到矩形”工具?

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()

1 个答案:

答案 0 :(得分:4)

这对我有用:

plt.get_current_fig_manager().toolbar.zoom()