Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can matplotlib animation output vector sequence?

Tags:

matplotlib

Is it possible to output sequence of files in vector format through matplotlib animation module?

For example:

...
anim = animation.FuncAnimation(...)
anim.save('animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])

outputs mp4 movie (through ffmpeg).

Can I instruct animation class to output sequence of vector files?

like image 372
theta Avatar asked Nov 13 '22 04:11

theta


1 Answers

To see what writers are available on your system use:

import matplotlib.animation as animation
print animation.writers.list()

You might need to write a new writer for what you want.

Edit

"FileWriters" from Matplotlib animation module seem to support only raster output. For FFMpegFileWriter() that's clear from documentation, and for FileMovieWriter() it can be derived if we initiate this class with unsupported format:

plt.rcParams['animation.frame_format'] = 'svg'

in which case Error is raised printing supported formats:

Unrecognized animation.frame_format string "'svg'": valid strings are ['rgba', 'tiff', 'jpeg', 'png', 'raw']

So Matplotlib animation module seems to work only with raster data.

like image 135
tacaswell Avatar answered Dec 10 '22 12:12

tacaswell