目前我正在处理一个要分析的曲面,4000个40x40帧。机械上它是一个4000帧的列表,它是一个40行的列表,它是一个40个数据点的列表。在
我使用funcanimation来查看它是如何随时间变化的,但是我遇到了一个问题。在这一点上,我有两个问题:
1)如何迭代帧一次,最终用于保存?在
2)如果我试图退出动画,为什么我当前的代码会给我一个旋转的海滩球?在
def update_fig(*args):
global currentNum, numSurfaces
currentNum += 1
if currentNum < numSurfaces:
print(currentNum)
im.set_array(testClass.surfaceList[currentNum])
return im,
else:
pass
def updatefig(*args):
global currentNum, numSurfaces
currentNum += 1
if currentNum > numSurfaces - 1:
currentNum = 0
print currentNum
im.set_array(testClass.surfaceList[currentNum])
return im,
ani = animation.FuncAnimation(fig, updatefig, frames=4000, interval=0.5, repeat=False, blit=False)
plt.show()
plt.close()
在开始动画之前,可以通过在帧上循环来保存图形。在
也可以使用动画保存图形
^{pr2}$第二种方法只适用于png图像,并且需要安装imagemagick。在
相关问题 更多 >
编程相关推荐