Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which backend should I use for animations with matplotlib?

I have an animation job that takes a long time and a lot of memory. I want to submit it to a TORQUE queue, but I can't use X on those machines. Since "default" matplotlib requires X, I need to import it like this:

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
...

What's passed to the use() method is called a backend. The documentation on backends can be found here.

Which backend should I use if I'm using matplotlib.animate() and want to save the animation as an mp4 or theora?

like image 488
Dan Avatar asked Nov 02 '22 01:11

Dan


1 Answers

The saving of movies is handled by the writer objects in the animation module and have nothing to do with the backend you set using use. If you need to run your script without X then setting use('Agg') is the correct thing to do.

See Generating movie from python without saving individual frames to files and the animation.writer module attribute (which is a registry of the writers matplotlib found on your system).

like image 106
tacaswell Avatar answered Nov 15 '22 06:11

tacaswell