如何在matplotlib中使用鼠标事件使此图像可伸缩。请帮忙。
这里是代码:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as image
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
fig = plt.figure()
X = [1, 2, 3, 4, 5, 6, 7]
Y = [1, 3, 4, 2, 5, 8, 6]
mainaxes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) # main axes
img = image.imread('https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png')
z = 0.3 + 0.3
imagebox = OffsetImage(img, zoom=z)
imgbox = AnnotationBbox(imagebox, (0.3,0.5), frameon=True)
mainaxes.add_artist(imgbox)
imgbox.draggable()
plt.show()