在Python中保存以下动画可能有什么问题?

时间:2014-03-23 16:57:35

标签: python

我是Python新手,想保存动画。这是一个最小的工作环境:

import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
from numpy import pi

X,Y = np.meshgrid(np.arange(0,2*np.pi,.2),np.arange(0,2*np.pi,.2) )  
U = np.cos(X)
V = np.sin(Y)

fig,ax = plt.subplots(1,1)
Q = ax.quiver( X, Y, U, V, pivot='mid', color='r', units='inches')

ax.set_xlim(0, 2*pi)
ax.set_ylim(0, 2*pi)

def update_quiver(num, Q, X, Y):
    U = np.cos(X + num*0.1)
    V = np.sin(Y + num*0.1)
    Q.set_UVC(U,V)
    return Q,


anim = animation.FuncAnimation(fig, update_quiver, fargs=(Q, X, Y),
    interval=10, blit=False)


mywriter = animation.FFMpegWriter()
anim.save('mymovie.mp4',writer=mywriter)

我收到错误消息:

mywriter = animation.FFMpegWriter()
AttributeError: 'module' object has no attribute 'FFMpegWriter'

任何帮助都将受到高度赞赏!

0 个答案:

没有答案