更新时间:2022-12-03 11:21:46
一种方法是:
fig, ax = plt.subplots(1, 1)
ax.imshow(np.random.rand(20, 20)
fig.canvas.toolbar.push_current() # save the 'un zoomed' view to stack
ax.set_xlim([5, 10])
ax.set_ylim([5, 10])
fig.canvas.toolbar.push_current() # save 'zoomed' view to stack
我不确定私有 push_current
是如何考虑的,正如我在评论中所说的,这是针对 1.5 重构的(
I am not sure how private push_current
is considered and as I said in the comments this is being refactored for 1.5 (https://github.com/matplotlib/matplotlib/wiki/Mep22).
请参见 https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backend_bases.py#L2600 了解如何实现平移/缩放.没有'zoom_window'命令的原因是用于静态图像,您只需使用 set_ * lim
.
See https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backend_bases.py#L2600 for how pan/zoom are implemented. The reason there isn't a 'zoom_window' command is for static images, you just use set_*lim
.