在Python中保存以下动画可能有什么错误?
我是Python新手,希望保存动画。以下是最低限度的工作环境:在Python中保存以下动画可能有什么错误?,python,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 =
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'
任何帮助都将不胜感激 看一看。@dredness谢谢!但其中可能包括什么?他们什么都没表现出来!!Thanks@Drewness他们的回答很含糊!你能解释一下吗?@drowness我在代码中包含的是你提到的链接中描述的简短答案,但它不起作用!!你知道为什么吗?谢谢,你安装了FFMpeg吗?您使用的matplotlib版本是什么?您发布的代码在使用matplotlib 1.3.1时确实适用于我。