因为我不知道你流的是什么,我写了一个通用的例子,它可以帮助你解决你的问题。在from pylab import *
import matplotlib.animation as animation
class Monitor(object):
""" This is supposed to be the class that will capture the data from
whatever you are doing.
"""
def __init__(self,N):
self._t = linspace(0,100,N)
self._data = self._t*0
def captureNewDataPoint(self):
""" The function that should be modified to capture the data
according to your needs
"""
return 2.0*rand()-1.0
def updataData(self):
while True:
self._data[:] = roll(self._data,-1)
self._data[-1] = self.captureNewDataPoint()
yield self._data
class StreamingDisplay(object):
def __init__(self):
self._fig = figure()
self._ax = self._fig.add_subplot(111)