【发布时间】:2011-06-27 13:09:47
【问题描述】:
我正在尝试为我的爪子数据创建一个 Matplotlib 动画,您可以在其中看到the entire pressure plate over time 上的压力分布(256x64 传感器,250 帧)。
我找到了一个working example on Matplotlib's own site 并设法让它处理我自己的数据。但是“动画”非常慢,我不知道如何加快速度。
这是一个 gif Joe Kington made in another answer 的示例,它与显示速度有关。考虑到测量是在 125 Hz 下进行的,这使得测量看起来非常缓慢。如果它以 30-60 fps 的速度运行,它可能会在 4 或 8 秒内运行,而不是当前的 20+。
我不介意使用完成工作所需的任何工具,只要有一些好的文档来弄清楚如何做。
所以我的问题是:如何加快这些动画的速度?
I've implemented Ignacio's suggestion 放入 t.Start(1),但是只有当图形这么大时它才会“正常”运行:
class PlotFigure(Frame):
""" This class draws a window and updates it with data from DataCollect
"""
def __init__(self):
Frame.__init__(self, None, -1, "Test embedded wxFigure")
#Varying the size of Figure has a big influence on the speed
self.fig = Figure((3,3), 75)
self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
EVT_TIMER(self, TIMER_ID, self.onTimer)
def init_plot_data(self):
self.datagen = DataCollect(array3d)
self.axes = self.fig.add_subplot(111)
self.axes.imshow(self.datagen.next().T)
def onTimer(self, evt):
self.data = self.datagen.next()
self.axes.imshow(self.datagen.next().T)
self.canvas.draw()
当我在动画期间调整窗口大小时,它会立即减速到爬行。这让我怀疑延迟不是放缓的唯一原因。 还有其他建议吗?如果你好奇,here's a link to one of the ASCII files.
【问题讨论】:
-
创建 png 文件并将它们拼接成动画 gif 怎么样?
-
这似乎不是一个很好的长期解决方案@ralu,因为我还必须将所有 gif 文件与数据一起存储。每次临床医生想要查看测量结果时生成 gif 图像似乎也很麻烦......我更愿意学习如何正确地做到这一点