how to clear pervious data in live 3d plot in while loop(Python3)

Viewed 34

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

0 Answers
Related