Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 动画问题_Python 2.7_Matplotlib - Fatal编程技术网

Python 2.7 动画问题

Python 2.7 动画问题,python-2.7,matplotlib,Python 2.7,Matplotlib,我正在尝试用我通过颜色映射矩阵获得的15张(在本例中)图像制作一个小电影,问题是无论输入的图像系列是什么,我获得的电影总是在显示13张图像后停止(对于每个尝试的数字,如果我有n张图像,电影只显示n-2张第一张图像)。 这是我的一段代码: im = plt.imshow(matrix_list[0],cmap=cm.hot_r,interpolation='none') plt.colorbar() #matrix_list is a list of 15 ndarrays of shape (

我正在尝试用我通过颜色映射矩阵获得的15张(在本例中)图像制作一个小电影,问题是无论输入的图像系列是什么,我获得的电影总是在显示13张图像后停止(对于每个尝试的数字,如果我有n张图像,电影只显示n-2张第一张图像)。 这是我的一段代码:

im = plt.imshow(matrix_list[0],cmap=cm.hot_r,interpolation='none')
plt.colorbar()

#matrix_list is a list of 15 ndarrays of shape (15,15)

def updatefig(j):
    # set the data in the axesimage object
    im.set_array(matrix_list[j])
    # return the artists set
    return im,
# kick off the animation
ani = animation.FuncAnimation(fig, updatefig,frames=range(len(matrix_list)), 
                          interval=1000, blit=True)
mywriter = animation.FFMpegWriter(fps=2.)
ani.save('my_movie_test.avi',writer=mywriter)

还有一点:当我在代码中添加plt.show()时,它显示了我所期望的内容,这是一部完整的电影,其中有15张图片定期重复。只是保存的电影在结尾之前无法读取。您是否尝试过其他格式,即保存到mp4?我正在做类似的工作,也许可以尝试将电影保存为gif格式。“my_movie_test.gif”,你可以在谷歌浏览器中打开它。你也试过不同的作家吗?