(self, x)
Update the plots with new data x. Assumes x is a one-dimensional array.
Update the plots with new data x. Assumes x is a one-dimensional array.
Update the plots with new data x . Assumes x is a one - dimensional array .
def update(self, x):
        """
        Update the plots with new data x. Assumes x is a one-dimensional array.
        """
        x = np.ravel([x])

        if not self._init:
            self.init(x.shape[0])

        assert x.shape[0] == self._data_len
        x = x.reshape((1, self._data_len))

        self._t += 1
        self._data = np.append(self._data, x, axis=0)

        t, tw = self._t, self._time_window
        t0, tf = (0, t) if t < tw else (t - tw, t)
        for i in range(self._data_len):
            self._plots[i].set_data(np.arange(t0, tf), self._data[t0:tf, i])

        x_range = (0, tw) if t < tw else (t - tw, t)
        self._ax.set_xlim(x_range)

        y_min, y_max = np.amin(self._data[t0:tf, :]), np.amax(self._data[t0:tf, :])
        self._ax.set_ylim(buffered_axis_limits(y_min, y_max, buffer_factor=1.25))

        self.draw()
def update ( self , x ) : x = np . ravel ( [ x ] ) if not self . _init : self . init ( x . shape [ 0 ] ) assert x . shape [ 0 ] == self . _data_len x = x . reshape ( ( 1 , self . _data_len ) ) self . _t += 1 self . _data = np . append ( self . _data , x , axis = 0 ) t , tw = self . _t , self . _time_window t0 , tf = ( 0 , t ) if t < tw else ( t - tw , t ) for i in range ( self . _data_len ) : self . _plots [ i ] . set_data ( np . arange ( t0 , tf ) , self . _data [ t0 : tf , i ] ) x_range = ( 0 , tw ) if t < tw else ( t - tw , t ) self . _ax . set_xlim ( x_range ) y_min , y_max = np . amin ( self . _data [ t0 : tf , : ] ) , np . amax ( self . _data [ t0 : tf , : ] ) self . _ax . set_ylim ( buffered_axis_limits ( y_min , y_max , buffer_factor = 1.25 ) ) self . draw ( )