Hey guys, has anyone figured out how to display a realtime 3D scatter plot using matplotlib. This is what I have at the moment, which doesn’t work. Just displays an empty 3d plot, and it doesn’t update. video is just a sequence of frames, each containing 3D coordinates and a hand skeleton. I am trying to eventually visualize a hand gesture in realtime. Any recommendations on how to make it work with streamlit. Otherwise, any recommendations on other frameworks other than matplotlib that can handle realtime plots ? Thanks
x = []
y = []
z = []
fig = plt.figure(figsize=(10, 10))
ax = plt.axes(projection = '3d')
graph = ax.scatter([], [], [], s=50, color='orange') # s argument here
c2.pyplot(fig)
for i in range(len(video)):
print(i)
frame=video[i]
for num in range(0,len(frame)-1) :
#print(i)
dx,dy,dz=frame[num]
dx_n,dy_n,dz_n=frame[num+1]
# Visualize 3D scatter plot
x.append(dx)
y.append(dy)
z.append(dz)
if i+1==len(frame)-1:
x.append(dx_n)
y.append(dy_n)
z.append(dz_n)
# Give labels
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_ylabel('z')
graph._offsets3d = (x, y, z)
time.sleep(0.01)