2

I use while loop to get a frame from camera and get point in frame then I need to plot a 3D plot. Now, I am using matplotlib plot a live 3d plot (line plot). Because of getting in live video and plot data, so that animation is not my choice.

I try to use:

plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

while True:
    ...
    ...
    for i in range(5):
       ax.plot(xs, ys, zs)
    plt.draw()
    plt.pause(0.01)

I can plot and update 3D plot, but screen will not clear old data.

If I use plt.clf, it will not show data in 3D plot.

Any other method can clean / redraw?

Thank you very much

shadow dk
  • 475
  • 1
  • 4
  • 15
  • The duplicate shows you what to do, namely to plot the line once and update its content with the two functions `set_data` and `set_3d_properties`. You may decide for yourself if you want to use a while loop for it, or if you want to use a `FuncAnimation`. Both would work, but I would clearly recommend `FuncAnimation`. There is no drawback of using a camera with that solution. – ImportanceOfBeingErnest Nov 15 '18 at 01:58

0 Answers0