This is very simple, rough code, but it does soemthing I have anted to accomplish for a very long time! I did this Jun22,2016.
See the codes in: /home/sco/sco/codes/python/cursor % cat a.1 # data 1.0 2.0 2.0 3.0 3.0 5.0 4.0 8.0 % cat cursor6.py from scomods.ascii_tools import * import matplotlib.pyplot as plt import numpy as np x = read1col('1','a.1') y = read1col('2','a.1') fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x,y,'ro') plt.axis([-1.0, 12.0, -1.0, 12.0]) def onclick(event): print('button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % (event.button, event.x, event.y, event.xdata, event.ydata)) if event.button == 3: plt.close() cid = fig.canvas.mpl_connect('button_press_event', onclick) plt.show() To run: % python cursor6.pyThe important thing is I recognize the X,Y of the cursor as well as which button was pressed.