|
From: John H. <jd...@gm...> - 2008-05-06 18:16:31
|
On Tue, May 6, 2008 at 11:17 AM, Matthew Czesarski
<mat...@gm...> wrote:
> So I'm pretty successful so far. The only problem is that the coordinates
> are in canvas coordinates, not plot coordinates. Now, rather embarrassingly,
> I can't figure out how to get this right. It seems to be the case that all
> the examples are in plot coordinates. As of course is the readout in the
> GUI itself. Is there a simple way to fix this or do I have convert it to
> some other backend? Or use something else instead of FigureCanvasGTK? This,
> to me, made the most sense to me at the time of writing, although I must
> confess I'm still pretty new to this.
Use mpl events -- they work across user interface toolkits and handle
stuff like which axes did you click in and what are the data
coordinates
def onclick(event):
print 'axes', event.inaxes
if event.inaxes is None: return
print 'canvas', event.x, event.y
print 'data', event.xdata, event.ydata
cid = fig.canvas.mpl_connect('button_press_event', onclick)
See matplotlib.backend_bases.Event and derived classes for details on
available attributes. See
matplotlib.backend_bases.FigureCanvasBase.mpl_connect for details on
valid signals,
|