有没有办法在 matplotlib.pyplot.show() 中选择默认鼠标 "mode" 作为缩放指针?
Is there a way to choose a default mouse "mode" in matplotlib.pyplot.show() to be the zoom pointer?
我有一个程序用来显示一堆不同的情节,我经常需要放大一个区域。我想知道是否有办法让默认光标缩放,就像我已经点击了放大镜一样。我想避免每次显示我的图时都必须单击 "magnifying glass"...我没有尝试任何解决方案,因为我在 matplotlib.pyplot 文档中找不到任何与远程接近的方法我想要做。
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1,2,3])
plt.show()
您可以拨打
fig.canvas.toolbar.zoom()
在显示绘图之前立即激活缩放模式。
完整示例:
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
# some code...
fig.canvas.toolbar.zoom()
plt.show()
我有一个程序用来显示一堆不同的情节,我经常需要放大一个区域。我想知道是否有办法让默认光标缩放,就像我已经点击了放大镜一样。我想避免每次显示我的图时都必须单击 "magnifying glass"...我没有尝试任何解决方案,因为我在 matplotlib.pyplot 文档中找不到任何与远程接近的方法我想要做。
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1,2,3])
plt.show()
您可以拨打
fig.canvas.toolbar.zoom()
在显示绘图之前立即激活缩放模式。
完整示例:
import matplotlib.pyplot as plt
fig,ax = plt.subplots()
# some code...
fig.canvas.toolbar.zoom()
plt.show()