import sys import matplotlib.pyplot as plt import numpy as np
t = np.arange(0.0, 1.0, 0.01) s = np.sin(2 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s)
defon_move(event): # get the x and y pixel coords x, y = event.x, event.y
if event.inaxes: ax = event.inaxes # the axes instance print('data coords %f %f' % (event.xdata, event.ydata))
defon_click(event): # get the x and y coords, flip y from top to bottom x, y = event.x, event.y if event.button == 1: if event.inaxes isnotNone: print('data coords %f %f' % (event.xdata, event.ydata))