I have the following problem. I'm building a wxpython application with a =
wxmpl PlotPanel. My ultimate need is to catch the X and Y graph =
coordinates of points I'm clicking on the graph. While using pylab this =
is almost trivial, it seems not if I'm using an embedded PlotPanel...
I've tried to mpl_connect the figure object to the button_click_event, =
print 'you click me!'
print 'in axes too!' =20
I receive an id from the mpl_connect method, but the click_me function =
is never called.
In the WxMPL documentation I also found this:
button_press_event(self, x, y, button, guiEvent=3DNone)
Backend derived classes should call this function on any mouse button =
press. x,y are the canvas coords: 0,0 is lower, left. button and key are =
as defined in MouseEvent
but I'm really unsure of its meaning/use. It is something to trap the =
I'm lost. Any help will be appreciated.
From: Ken McIvor <mcivor@ii...> - 2006-04-06 13:20:33
Massimo contacted me off-list to let me know my last email on the
topic was overlooked. For posterity, here's the short and sweet recipe.
def __init__ ...
# create the plot panel
self.control = wxmpl.PlotPanel(self, -1)
# register to receive WxMpl PointEvents
wxmpl.EVT_POINT(self, self.control.GetId(), self.OnPlotPoint)
def OnPlotPoint(self, evt):
# the PointEvent object `evt' contains some useful
# the axes that was clicked on
print ' axes =', evt.axes
# matplotlib's X&Y coordinates (not quite the same as
print ' mpl x =', evt.x
print ' mpl y =', evt.y
# axes' X&Y coordinates (the data value that was clicked on)
print ' data x =', evt.xdata
print ' data y =', evt.ydata