【问题标题】:Which backend should I use for animations with matplotlib?我应该将哪个后端用于带有 matplotlib 的动画?
【发布时间】:2014-04-21 22:33:21
【问题描述】:

我的动画工作需要很长时间和大量内存。我想将它提交到TORQUE 队列,但我不能在那些机器上使用 X。由于“默认”matplotlib 需要 X,我需要像这样导入它:

import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
...

传递给use() 方法的内容称为后端。后端的文档可以在here找到。

如果我使用 matplotlib.animate() 并希望将动画保存为 mp4 或 theora,我应该使用哪个后端?

【问题讨论】:

    标签: python animation matplotlib backend


    【解决方案1】:

    电影的保存由animation 模块中的writer 对象处理,与您使用use 设置的后端无关。如果您需要在没有 X 的情况下运行脚本,那么设置 use('Agg') 是正确的做法。

    请参阅 Generating movie from python without saving individual frames to filesanimation.writer 模块属性(这是在您的系统上找到的编写器 matplotlib 的注册表)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 2019-08-13
      • 2022-11-15
      • 1970-01-01
      • 2018-04-20
      • 2016-08-26
      相关资源
      最近更新 更多