【问题标题】:Python - animation with matplotlib.pyplotPython - 使用 matplotlib.pyplot 制作动画
【发布时间】:2011-02-02 13:23:06
【问题描述】:

如何使用流行的 matplotlib 库创建动画图表?我对 GIF 动画特别感兴趣。

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    matplotlib 文档在animation 上提供了完整的示例部分(另请参阅此scipy 教程)。然而,大多数涉及使用各种 GUI 小部件后端。那里有一个“电影演示”,它展示了如何生成一系列 PNGS 的 avi。

    要制作动画 GIF,我认为您的选择是 pretty limited。最后我检查了PIL didn't support them。但是,您可以使用 pyplot 的 savefig 生成一系列 PNG,然后使用对 ImageMagick 或 mencoder 的调用将它们拼接在一起。

    【讨论】:

      【解决方案2】:

      这个问题有点老了,但我会回答以防万一有人在这里崩溃,这很有用。

      所以现在看来​​,在 matplotlib 中最好的方法是使用它们提供的功能:

      http://matplotlib.org/api/animation_api.html#module-matplotlib.animation

      它们还包括一些有用的示例,您可以根据需要轻松修改这些示例(尽管如果您没有以面向类的方式使用 matplotlib,则很难理解它们的工作原理):

      http://matplotlib.org/examples/animation/

      最后只是为了补充这些信息,Jake VanderPlas 有一个更完整的教程和一个关于 Python 可视化未来的简要回顾:

      教程: http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/

      关于可视化的文章: http://jakevdp.github.io/blog/2013/03/23/matplotlib-and-the-future-of-visualization-in-python/

      【讨论】:

        【解决方案3】:

        2017 年更新

        Matplotlib 有 animation 模块,您可以在其中找到 ImageMagickFileWriter 类。它被宣传为“基于文件的动画 gif 编写器。”

        文档:http://matplotlib.org/api/_as_gen/matplotlib.animation.ImageMagickFileWriter.html#matplotlib.animation.ImageMagickFileWriter

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2010-12-16
          • 2017-03-12
          • 2023-03-08
          相关资源
          最近更新 更多