victor
victor

Reputation: 6768

Matplotlib animate over an image

I'm trying to animate a bunch of constantly updating points over an image (imagine making a plotted dot move diagonally across some image). I've looked at the animate examples here: http://matplotlib.org/examples/animation/dynamic_image.html, but I'm not sure how to keep the same image while clearing out all previous dots, then redrawing them. Any ideas?

Upvotes: 2

Views: 2922

Answers (1)

tacaswell
tacaswell

Reputation: 87556

You do not need to clear the figure between every frame

#initial data 
ln, = ax.plot(x,y)
#...some loop code
    ln.set_xdata(new_x)
    ln.set_ydata(new_y)

Can you show some code of what you have tried, it will make it easier to give a more concrete answer.

Also see: using matplotlib's quiver in a loop efficiently, Visualization of 3D-numpy-array frame by frame

Upvotes: 1

Related Questions