【发布时间】:2011-11-28 15:37:20
【问题描述】:
我希望使用下面的 onmove 函数在 matplotlib 中创建自定义悬停动作。 将 x 和 event.x 中现有数据点值转换为另一个坐标系(例如点)的最佳方法是什么,以便我可以检测 event.x 何时在 p 点的任何数据点?我知道选择器事件,但不想使用它,因为它基于点击,而不是悬停。
fig = figure()
ax1 = subplot(111)
x = linspace(0,10,11)
y = x**2
ax1.plot(x,y)
fig.canvas.mpl_connect('motion_notify_event', onmove)
p = 5
def onmove(event):
if event.inaxes:
#Detect if mouse was moved within p points of any value in x
【问题讨论】:
标签: matplotlib