带有图像切片的 matplotlib 交互式绘图

matplotlib interactive plot with slices of image

我如何制作像此处显示的那样的交互式绘图?我想显示一张图像,其中包含在某个点拍摄的图像的 x 和 y 切片,可以通过单击图像进行调整。

我知道这是用 Chaco 制作的,但由于 Chaco 与 python3 不兼容,最好使用 matplotlib 或 bokeh。

使用 tacaswells 的建议,我发现泡泡糖中的 cross_section_2d 正是我要找的。

首先我从 github https://github.com/Nikea/bubblegum.git

安装了 bubblegum

然后下面设置一个cross_section图像

import matplotlib.pyplot as plt
import numpy as np
from bubblegum.backend.mpl.cross_section_2d import CrossSection
fig= plt.figure()
cs= CrossSection(fig)
img= np.random.rand(100,100)
cs.update_image(img)
plt.show()

谢谢!