# draw one point using subplot
# move the curve to the clicked locaction
import matplotlib.pyplot as plt
import numpy as np
import pdb
x = np.linspace(0, 2*3.14, 100)
y = np.sin(x)
def onPress(event):
print(event.xdata, event.ydata)
#print(help(pnt.set_data))
x = pnt.get_xdata()
y = pnt.get_ydata()
ymax = np.max(y)
yind = np.argmax(y)
xmax = x[yind]
y = y + event.ydata - ymax
x = x + event.xdata - xmax
pnt.set_data(x, y)
pnt.figure.canvas.draw()
fig, ax = plt.subplots()
pnt, = ax.plot(x, y, 'ro')
pnt.figure.canvas.mpl_connect('button_press_event', onPress)
#pnt.figure.canvas.mpl_connect('motion_notify_event', onPress)
plt.show()