Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import matplotlib.animation as animation
- from mpl_toolkits.mplot3d import Axes3D
- import time
- import numpy as np
- fig = plt.figure()
- ax1 = fig.add_subplot(111, projection='3d')
- def animate(i):
- #This is sample of reading from the file while keep updating the file:
- try:
- pullData = open("tteeth_extended_calibration.csv","r").read()
- sampleArray = pullData.split('\n')
- #Obviously, the data in sampleData.txt file should be in this format:
- #x1,y1
- #x2,y2
- #.
- #.
- #=============================================
- #this is just a sample array, you can easily replace
- #numbers in this array and see the cahnges.
- #Each index is a point and first value is x, second value is y
- #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']
- #print (sampleArray)
- #print("_______\n")
- xar = []
- yar = []
- for eachLine in sampleArray:
- if len(eachLine)>1:
- try:
- xmin,ymin,zmin,xmax,ymax,zmax,g,t = eachLine.split(',')
- # xar.append(int(xmin))
- # xar.append(int(xmax))
- # yar.append(int(ymin))
- # yar.append(int(ymax))
- ax1.scatter(int(xmin), int(ymin), int(0), c='b', marker='o');
- ax1.scatter(int(0), int(ymin), int(zmin), c='r', marker='o');
- ax1.scatter(int(xmin), int(0), int(zmin), c='g', marker='^');
- except ValueError:
- print "Oops again"
- ax1.clear()
- #ax1.scatter(xar,yar)
- except IOError:
- print "OOOOOps"
- ani = animation.FuncAnimation(fig, animate, interval=100)
- #INTERVAL argument for funcanimatiin is basically the speed of updating,
- # You can make it faster by decreasing the value
- plt.show()
Add Comment
Please, Sign In to add comment