# 2D data plotted in a 3D plot by adding time flow dimension

hi,

I try to make my question as clear as possible. I need to plot 2 dimensional
data coming from the serial onto a 3d plot with the third axes made of time
flowing.

I wrote this code (it's just one of the many tries). It's about the plotting
only, not worring about buffer from serial etc etc...

With set_data i have a static picture, with ax.plot at every for index I
can't understand what's happening.

any help would be really appreciate.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/2D-data-plotted-in-a-3D-plot-by-adding-time-flow-dimension-tp45468.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Looks like nabble swallowed your code snippet. Here it is:

import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import numpy.random as rnd
import numpy as np
TILL = 200 # just to have an end in the for loop
def SSI(t): #Simulated Serial Input
T = np.asarray(t)
X = np.sin(T)
Y = np.cos(T) return X,Y,T
t = range(0,TILL/2)
plt.ion()
fig = plt.figure()
ax = p3.Axes3D(fig)
#ax = fig.gca(projection=‘3d’) # same result as Axes3D
X,Y,T = SSI(t)
g, = ax.plot(X,Y,T) # for set_data method
#ax.plot(X,Y,T) # not using set_data method
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 = SSI(t)
#plt.plot(X,Y,T)
g.set_data(X,Y) # #ax.set_zlim(i,i+100) # to make the time axis sliding
plt.draw()
#g.axes.figure.canvas.draw() # Same result as plt.draw()

``````
``````

Unfortunately, IIRC, set_data() for the 3d objects is probably not what you want. See https://github.com/matplotlib/matplotlib/issues/1483.

Ben Root

···

On Sat, May 2, 2015 at 7:05 AM, arjunascagnetto <arjuna.scagnetto@…287…> wrote:

hi,

I try to make my question as clear as possible. I need to plot 2 dimensional

data coming from the serial onto a 3d plot with the third axes made of time

flowing.

I wrote this code (it’s just one of the many tries). It’s about the plotting

only, not worring about buffer from serial etc etc…

With set_data i have a static picture, with ax.plot at every for index I

can’t understand what’s happening.

any help would be really appreciate.

View this message in context: http://matplotlib.1069221.n5.nabble.com/2D-data-plotted-in-a-3D-plot-by-adding-time-flow-dimension-tp45468.html

Sent from the matplotlib - users mailing list archive at Nabble.com.

One dashboard for servers and applications across Physical-Virtual-Cloud

Widest out-of-the-box monitoring support with 50+ applications

Performance metrics, stats and reports that give you Actionable Insights

Deep dive visibility with transaction tracing using APM Insight.

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

yes you've got it. Thanks for the link. Just some days after posting this
question i succeced and i found out the set_3d_proprierties function doing
the magic. Here the clean code.

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

t=np.linspace(0,10,1000)
x=np.sin(t)
y=np.cos(t)

plt.ion()

fig = plt.figure()
ax = fig.gca(projection='3d')
line, = ax.plot(x,y,t)

for i in range(400):
t=np.linspace(i,i+30,1000)
ax.set_zlim(i,i+100)
x=np.sin(t)
y=np.cos(t)
line.set_data(x,y)
line.set_3d_properties(t)
plt.draw()

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/2D-data-plotted-in-a-3D-plot-by-adding-time-flow-dimension-tp45468p45493.html
Sent from the matplotlib - users mailing list archive at Nabble.com.