【发布时间】:2021-10-13 00:54:05
【问题描述】:
关于matplotlib项目动画的大多数问题都详细说明了以线条格式绘制数据,这似乎不适用于图像。
我想在子图中显示三个系列的图像,并为图形设置动画以显示系列中的每个项目。目前,我使用子图创建图形,并在for 循环中生成我想在动画中显示的图形列表。我正在使用一个 jupyter 笔记本,所以我将它导出到一个 jshtml 框架。
我的代码:
fig, (ax0, ax1, ax2) = plt.subplots(nrows=1, ncols=3,
figsize=(12, 6))
fis = []
for i in range(0,len(filename_list),4): #show every 4th image in series
ax0.set_title('Raw image')
ax0.imshow(plt.imread(filename_list[i]),animated=True)
ax1.set_title('Manually cropped image')
ax1.imshow(plt.imread( (filename_list[i].parent / 'cropped' /filename_list[i].name) ) ,animated=True)
ax2.set_title('Cropped image after re-centering')
ax2.imshow(plt.imread( (filename_list[i].parent / 'cropped_corr' /filename_list[i].name) ) ,animated=True)
fis.append([fig])
ani = animation.ArtistAnimation(fig, fis, interval=500, blit=False, repeat_delay=1000)
plt.close()
HTML(ani.to_jshtml())
这会产生一个有效的 jshtml 动画,但子图不会改变。 如何制作动画以更新子图?我不知道如何制作一个更新每一帧的动画函数。
谢谢!
【问题讨论】:
标签: python matplotlib