python 2.7 - matplotlib detect object upon mouse event -


is there way detect matplotlib object mouse focused on ? piece of code illustrates want

self.canvas.mpl_connect("motion_notify_event", self.on_focus)  def on_focus(self, event):     # mouse position in figure     figpos = (event.x,event.y)     # mouse position in axes if focusing on axes     axespos = event.xdata, event.ydata     # axes instance if mouse focusing on axes     axes = event.inaxes     # object (any matplotlib object, text, box, ...) mouse focused on     obj = event.?????? 

thanks

try axes.hitlist:

import matplotlib.pyplot plt  fig = plt.figure() ax = fig.add_subplot(111) ax.plot(range(10),range(10))  def on_focus(event):     print ax.hitlist(event) fig.canvas.mpl_connect("motion_notify_event", on_focus) plt.show() 

but if want highlight can use built-in:

fig.canvas.mpl_connect("motion_notify_event",fig.canvas.onhilite)


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -