Skip to content

Instantly share code, notes, and snippets.

@ceptreee
Created March 29, 2018 13:07
Show Gist options
  • Save ceptreee/2751197679fc39cda16cd107668ea544 to your computer and use it in GitHub Desktop.
Save ceptreee/2751197679fc39cda16cd107668ea544 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
ln.set_data(x,y)
plt.draw()
plt.figure()
ln, = plt.plot([],[],'x',markersize=10)
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
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