matplotlib 动画可以输出向量序列吗?

the*_*eta 5 matplotlib

是否可以通过 matplotlib动画模块以矢量格式输出文件序列?

例如:

...
anim = animation.FuncAnimation(...)
anim.save('animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
Run Code Online (Sandbox Code Playgroud)

输出 mp4 电影(通过 ffmpeg)。

我可以指示动画类输出矢量文件序列吗?

tac*_*ell 1

要查看您的系统上可用的编写器,请使用:

import matplotlib.animation as animation
print animation.writers.list()
Run Code Online (Sandbox Code Playgroud)

writer您可能需要为您想要的内容编写一个新的。

编辑

Matplotlib 动画模块中的“FileWriters”似乎仅支持光栅输出。从文档中可以FFMpegFileWriter()清楚地看出这一点,并且FileMovieWriter()如果我们使用不受支持的格式启动此类,则可以派生出这一点:

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

在这种情况下,打印支持的格式时会出现错误:

无法识别的animation.frame_format字符串“'svg'”:有效字符串为['rgba','tiff','jpeg','png','raw']

所以 Matplotlib 动画模块似乎只适用于栅格数据。