I need to plot a continous flow of data coming from the serial. Data has 2 dimensions, let's say X and Y. I would like to plot these data against a third dimension, the time flowing. I wrote this code, but it doesn't do what i want.
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import mpl_toolkits.mplot3d.axes3d as p3
import numpy.random as rnd
import numpy as np
TILL = 200
def func(t):
X = np.sin(t)
Y = np.cos(t)
T = t
return X,Y,T
t = range(0,200)
plt.ion()
fig = plt.figure()
ax = fig.gca(projection='3d')
X,Y,T = func(t)
g, = ax.plot(X,Y,T)
plt.ylim([-1.5,1.5])
plt.xlim([-1.5,1.5])
for i in range(TILL):
val = rnd.random(1)
t.append(val)
t.pop(0)
X,Y,T = func(t)
g.set_data(X,Y)
ax.set_zlim(i,i+100)
plt.draw()
It's as the problem of plotting a function from R to R square with sliding temporal axis.
Any help would be appreciate.
Thanks