Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. fig.canvas.mpl_disconnect(cid)
  2.  
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5.  
  6. x = np.arange(-10,10)
  7. y = x**2
  8.  
  9. fig = plt.figure()
  10. ax = fig.add_subplot(111)
  11. ax.plot(x,y)
  12.  
  13. coords = []
  14.  
  15. def onclick(event):
  16. global ix, iy
  17. ix, iy = event.xdata, event.ydata
  18. print 'x = %d, y = %d'%(
  19. ix, iy)
  20.  
  21. global coords
  22. coords.append((ix, iy))
  23.  
  24. if len(coords) == 2:
  25. fig.canvas.mpl_disconnect(cid)
  26.  
  27. return coords
  28. cid = fig.canvas.mpl_connect('button_press_event', onclick)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement