[Matplotlib-users] mouse cursor coordinates
grivet
grivet at cnrs-orleans.fr
Mon May 30 06:17:23 EDT 2016
Hello,
I want to retrieve the mouse cursor coordinates when i click inside a
figure. I have tried a variety ef example programs, such as
from pylab import *
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(np.random.rand(10))
def onclick(event):
print("button=%d, x=%d, y=%d, xdata=%f, ydata=%f" %(
event.button, event.x, event.y, event.xdata, event.ydata))
cid = fig.canvas.mpl_connect('button_press_event', onclick)
ax.set_title("click on figure")
show()
The figure gets plotted, then nothing happens: the program simply ends
and focus retruns to the IPython console.
I am using distribution Anaconda/Python35/Spyder under Win7-64. What did
I miss ?
Thank you for your help,
JP Grivet
More information about the Matplotlib-users
mailing list