Skip to content

Instantly share code, notes, and snippets.

@ceptreee
Last active July 8, 2019 06:28
Show Gist options
  • Save ceptreee/ab6130b3d18fd0eb5d585ac7fc68c19e to your computer and use it in GitHub Desktop.
Save ceptreee/ab6130b3d18fd0eb5d585ac7fc68c19e to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
def motion(event):
x = event.xdata
y = event.ydata
if (x is None) or (y is None):
return
ln.set_data(x,y)
print('(x,y) = (%.2f,%.2f)' % (x,y))
plt.draw()
plt.figure()
ln, = plt.plot([],[],'x',markersize=10)
plt.xlim([-1,1])
plt.ylim([-1,1])
plt.grid()
plt.connect('motion_notify_event', motion)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
def motion(event):
x = event.xdata
y = event.ydata
ln.set_data(x,y)
plt.draw()
plt.figure()
ln, = plt.plot([],[],'x',markersize=10)
plt.connect('motion_notify_event', motion)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment