plotting.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:live-serial 作者: rosenbrockc 项目源码 文件源码
def _draw_frame(self, iframe):
        """Draws the latest frame for each sensor on the relevant plot.
        """
        for sensor in self._plotorder:
            #First, we get the latest data point from the live feed.
            ldata = self.livefeed.read_data(sensor)
            if len(ldata) < 2: # pragma: no cover
                #We don't have anything reasonable to plot; exit gracefully.
                continue

            t = ldata[0]
            self.ts[sensor].append(t)

            for vindex in self._vindices[sensor]:
                self.ys[(sensor, vindex)].append(ldata[vindex])
                ts, ys = self.ts[sensor], self.ys[(sensor, vindex)]
                self.lines[(sensor, vindex)].set_data(ts, ys)
            if t > self.window: # pragma: no cover
                # We don't want the tests to run long enough for this window to
                # kick in (at least for the moment).
                self.axes[sensor].set_xlim((self.ts[sensor][0], t + 2.5))

            self.axes[sensor].relim() # reset intern limits of the current axes 
            self.axes[sensor].autoscale_view()   # reset axes limits 

        self._drawn_artists = self.lines.values()
        if self.testmode:
            self._timer = Timer(self.interval, self._draw_frame, (0,))
            self._timer.start()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号