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

时间:2013-05-30 17:35:07

标签: matplotlib

是否可以通过matplotlib animation module输出矢量格式的文件序列?

例如:

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

输出mp4电影(通过ffmpeg)。

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

1 个答案:

答案 0 :(得分:1)

要查看系统上可用的作者:

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

您可能需要根据需要编写新的writer

修改

来自Matplotlib动画模块的“FileWriters”似乎只支持光栅输出。对于文档中明确的FFMpegFileWriter(),以及FileMovieWriter(),如果我们使用不支持的格式启动此类,则可以派生它:

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

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

  

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

因此,Matplotlib动画模块似乎只适用于栅格数据。