Guest User

Untitled

a guest
Jun 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import matplotlib.animation as animation
  3. from mpl_toolkits.mplot3d import Axes3D
  4. import time
  5. import numpy as np
  6.  
  7. fig = plt.figure()
  8. ax1 = fig.add_subplot(111, projection='3d')
  9.  
  10. def animate(i):
  11. #This is sample of reading from the file while keep updating the file:
  12. try:
  13. pullData = open("tteeth_extended_calibration.csv","r").read()
  14. sampleArray = pullData.split('\n')
  15. #Obviously, the data in sampleData.txt file should be in this format:
  16. #x1,y1
  17. #x2,y2
  18. #.
  19. #.
  20. #=============================================
  21.  
  22. #this is just a sample array, you can easily replace
  23. #numbers in this array and see the cahnges.
  24. #Each index is a point and first value is x, second value is y
  25. #sampleArray = ['1,2', '2,3', '3,6', '4,9', '5,4', '6,7', '7,7', '8,4', '9,3', '10,7', '100,2', '110,2']
  26. #print (sampleArray)
  27. #print("_______\n")
  28. xar = []
  29. yar = []
  30. for eachLine in sampleArray:
  31. if len(eachLine)>1:
  32. try:
  33. xmin,ymin,zmin,xmax,ymax,zmax,g,t = eachLine.split(',')
  34. # xar.append(int(xmin))
  35. # xar.append(int(xmax))
  36. # yar.append(int(ymin))
  37. # yar.append(int(ymax))
  38. ax1.scatter(int(xmin), int(ymin), int(0), c='b', marker='o');
  39. ax1.scatter(int(0), int(ymin), int(zmin), c='r', marker='o');
  40. ax1.scatter(int(xmin), int(0), int(zmin), c='g', marker='^');
  41.  
  42. except ValueError:
  43. print "Oops again"
  44. ax1.clear()
  45. #ax1.scatter(xar,yar)
  46. except IOError:
  47. print "OOOOOps"
  48.  
  49. ani = animation.FuncAnimation(fig, animate, interval=100)
  50. #INTERVAL argument for funcanimatiin is basically the speed of updating,
  51. # You can make it faster by decreasing the value
  52. plt.show()
Add Comment
Please, Sign In to add comment