import numpy as np from .globals import * from .plotim import linear_plot class Plot(linear_plot): def __init__(self, nPoints, xaxis, yaxis, nGraphs = 1, **kwargs): self.xs = np.ndarray(shape=(nGraphs, nPoints), dtype=float) self.xs.fill(0) self.ys = np.ndarray(shape=(nGraphs, nPoints), dtype=float) self.ys.fill(float('NaN')) self.i = 0 self.nPoints = nPoints self.nGraphs = nGraphs linear_plot.__init__(self, **kwargs) self.set_scale(xaxis, yaxis) def update(self, ys, xs=None, visible=True): for g in range(self.nGraphs): if xs == None: self.xs[g][self.i] = self.i else: self.xs[g] = np.append([xs[g]], self.xs[g][:-1]) self.ys[g] = np.append([ys[g]], self.ys[g][:-1]) if visible: self.plot_data(self.xs, self.ys) self.i = (self.i+1) % self.nPoints