(self, x, t=None)
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, t=None):
        """
        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])

        if not t:
            t = self._t

        assert x.shape[0] == self._data_len
        t = np.array([t]).reshape((1, 1))
        x = x.reshape((self._data_len, 1))
        mean = np.mean(x).reshape((1, 1))

        self._t += 1
        self._ts = np.append(self._ts, t, axis=1)
        self._data = np.append(self._data, x, axis=1)
        self._data_mean = np.append(self._data_mean, mean, axis=1)

        for i in range(self._data_len):
            self._plots[i].set_data(self._ts, self._data[i, :])
        self._plots_mean.set_data(self._ts, self._data_mean[0, :])

        self._ax.set_xlim(self._ts[0, 0]-0.5, max(self._ts[-1, 0], self._min_itr)+0.5)

        y_min, y_max = np.amin(self._data), np.amax(self._data)
        self._ax.set_ylim(buffered_axis_limits(y_min, y_max, buffer_factor=1.1))
        self.draw()
def update ( self , x , t = None ) : x = np . ravel ( [ x ] ) if not self . _init : self . init ( x . shape [ 0 ] ) if not t : t = self . _t assert x . shape [ 0 ] == self . _data_len t = np . array ( [ t ] ) . reshape ( ( 1 , 1 ) ) x = x . reshape ( ( self . _data_len , 1 ) ) mean = np . mean ( x ) . reshape ( ( 1 , 1 ) ) self . _t += 1 self . _ts = np . append ( self . _ts , t , axis = 1 ) self . _data = np . append ( self . _data , x , axis = 1 ) self . _data_mean = np . append ( self . _data_mean , mean , axis = 1 ) for i in range ( self . _data_len ) : self . _plots [ i ] . set_data ( self . _ts , self . _data [ i , : ] ) self . _plots_mean . set_data ( self . _ts , self . _data_mean [ 0 , : ] ) self . _ax . set_xlim ( self . _ts [ 0 , 0 ] - 0.5 , max ( self . _ts [ - 1 , 0 ] , self . _min_itr ) + 0.5 ) y_min , y_max = np . amin ( self . _data ) , np . amax ( self . _data ) self . _ax . set_ylim ( buffered_axis_limits ( y_min , y_max , buffer_factor = 1.1 ) ) self . draw ( )