Home > Software engineering >  How to save a matplotlib.pause animation to video?
How to save a matplotlib.pause animation to video?

Time:10-07

I have an animation created with plt.pause as below...

import matplotlib.pyplot as plt

for i in range(10):
    plt.scatter(0, i)
    plt.pause(0.01)

plt.show()

How can I save this as a video file, e.g. a .mp4 file?

CodePudding user response:

First, I have to redefine the plotting as a function with the plotted point given by a frame i. plt.pause() can be replaced by matplotlib.animate. Finally, I used a package suggested Result

To tweak the length of the animation, check out the result

  • Related