根据 mpldatacursor 0.7.1项目描述,它说“mpldatacursor 为 matplotlib 提供交互式“数据光标”(可点击的注释框)。
我使用项目描述中的代码,但我只是得到图像。当我单击图像时,它不显示注释框。
我的 Python 版本是 3.8,Pycharm 版本是专业版 2019.2。顺便说一句,我运行代码时没有错误。
有谁知道为什么?
import matplotlib.pyplot as plt
import numpy as np
from mpldatacursor import datacursor
data = np.arange(100).reshape((10,10))
fig, axes = plt.subplots(ncols=2)
axes[0].imshow(data, interpolation='nearest', origin='lower')
axes[1].imshow(data, interpolation='nearest', origin='upper',
extent=[200, 300, 400, 500])
datacursor(display='single')
fig.suptitle('Click anywhere on the image')
plt.show()