通过 matplotlib 的 Imagemagick 似乎在创建时截断了 GIF 长度
Imagemagick via matplotlib appears to be truncating GIF length on creation
我目前正在使用 python matplotlib 创建一些动画图形,然后使用 ImageMagick 将它们转换为 gif。
这是创建动画的代码行:
anim = animation.FuncAnimation(fig, animate, init_func = init, interval = 20, blit = True)
matplotlib 使用 plt.show()
愉快地为这些设置动画
当我将其导出为 gif 时,没有出现任何错误,创建的 gif 反映了 plot.show()
显示的内容,但它只是动画的前 ~25% (1.1MB)。
这是导出代码:
anim.save(filepath/name, writer = 'imagemagick')
我四处寻找,但找不到任何可以说明为什么会发生这种情况的信息。在我点击的任何地方配置的文件大小或帧似乎都没有限制。如果创建的图像之一已损坏,我希望 plt.show()
动画失败 and/or 将收到错误消息。
非常感谢收到的任何指示 - 我找不到解开这个的线程!
根据调查,除非另有说明,否则保存功能似乎默认为 100 帧。我在文档中看不到这一点,但使用了 iterate() 函数的计数来查看它被调用了多少次。
此限制不适用于 plt.show()
函数,因此会出现差异。
将数据点数添加到帧参数可以解决此问题。即
anim = animation.FuncAnimation(fig, animate, frames = data_points, init_func = init, interval = 20, blit = True)
anim.save(filepath/name, writer = 'imagemagick')
我目前正在使用 python matplotlib 创建一些动画图形,然后使用 ImageMagick 将它们转换为 gif。
这是创建动画的代码行:
anim = animation.FuncAnimation(fig, animate, init_func = init, interval = 20, blit = True)
matplotlib 使用 plt.show()
当我将其导出为 gif 时,没有出现任何错误,创建的 gif 反映了 plot.show()
显示的内容,但它只是动画的前 ~25% (1.1MB)。
这是导出代码:
anim.save(filepath/name, writer = 'imagemagick')
我四处寻找,但找不到任何可以说明为什么会发生这种情况的信息。在我点击的任何地方配置的文件大小或帧似乎都没有限制。如果创建的图像之一已损坏,我希望 plt.show()
动画失败 and/or 将收到错误消息。
非常感谢收到的任何指示 - 我找不到解开这个的线程!
根据调查,除非另有说明,否则保存功能似乎默认为 100 帧。我在文档中看不到这一点,但使用了 iterate() 函数的计数来查看它被调用了多少次。
此限制不适用于 plt.show()
函数,因此会出现差异。
将数据点数添加到帧参数可以解决此问题。即
anim = animation.FuncAnimation(fig, animate, frames = data_points, init_func = init, interval = 20, blit = True)
anim.save(filepath/name, writer = 'imagemagick')