Beispiel #1
0
    def _plot_unit(self, pinfo, ax):
        x = pinfo.pop('x')
        y = pinfo.pop('y')
        se = self.params['se']
        level = self.params['level']
        method = self.params['method']
        span = self.params['span']
        window = self.params['window']
        pinfo['label'] = self.params['label']

        if window is None:
            window = int(np.ceil(len(x) / 10.0))

        idx = np.argsort(x)
        x = np.array(x)[idx]
        y = np.array(y)[idx]

        if method == "lm":
            y, y1, y2 = smoothers.lm(x, y, 1-level)
        elif method == "ma":
            y, y1, y2 = smoothers.mavg(x, y, window=window)
        else:
            y, y1, y2 = smoothers.lowess(x, y, span=span)

        facecolor = pinfo.pop('facecolor')
        alpha = pinfo.pop('alpha')
        ax.plot(x, y, **pinfo)

        if se==True:
            pinfo.pop('color')
            pinfo.pop('linewidth')
            pinfo['facecolor'] = facecolor
            pinfo['alpha'] = alpha
            ax.fill_between(x, y1, y2, **pinfo)
Beispiel #2
0
    def plot_layer(self, layer):
        layer = {k: v for k, v in layer.items() if k in self.VALID_AES}
        layer.update(self.manual_aes)

        if 'x' in layer:
            x = layer.pop('x')
        if 'y' in layer:
            y = layer.pop('y')
        if 'se' in layer:
            se = layer.pop('se')
        else:
            se = None
        if 'span' in layer:
            span = layer.pop('span')
        else:
            span = 2/3.
        if 'method' in layer:
            method = layer.pop('method')
        else:
            method = None

        if method == "lm":
            y, y1, y2 = smoothers.lm(x, y)
        elif method == "ma":
            y, y1, y2 = smoothers.mavg(x, y)
        else:
            y, y1, y2 = smoothers.lowess(x, y)
        idx = np.argsort(x)
        x = np.array(x)[idx]
        y = np.array(y)[idx]
        y1 = np.array(y1)[idx]
        y2 = np.array(y2)[idx]
        plt.plot(x, y, **layer)
        if se==True:
            plt.fill_between(x, y1, y2, alpha=0.2, color="grey")
Beispiel #3
0
    def plot_layer(self, layer):
        layer = {k: v for k, v in layer.iteritems() if k in self.VALID_AES}
        layer.update(self.manual_aes)

        if 'x' in layer:
            x = layer.pop('x')
        if 'y' in layer:
            y = layer.pop('y')
        if 'se' in layer:
            se = layer.pop('se')
        else:
            se = None
        if 'span' in layer:
            span = layer.pop('span')
        else:
            span = 2 / 3.
        if 'method' in layer:
            method = layer.pop('method')
        else:
            method = None

        if method == "lm":
            y, y1, y2 = smoothers.lm(x, y)
        elif method == "ma":
            y, y1, y2 = smoothers.mavg(x, y)
        else:
            y, y1, y2 = smoothers.lowess(x, y)
        idx = np.argsort(x)
        x = np.array(x)[idx]
        y = np.array(y)[idx]
        y1 = np.array(y1)[idx]
        y2 = np.array(y2)[idx]
        plt.plot(x, y, **layer)
        if se == True:
            plt.fill_between(x, y1, y2, alpha=0.2, color="grey")
Beispiel #4
0
    def plot_layer(self, layer):
        layer = dict((k, v) for k, v in layer.items() if k in self.VALID_AES)
        layer.update(self.manual_aes)

        if 'x' in layer:
            x = layer.pop('x')
        if 'y' in layer:
            y = layer.pop('y')
        if 'se' in layer:
            se = layer.pop('se')
        else:
            se = None
        if 'span' in layer:
            span = layer.pop('span')
        else:
            span = 2/3.
        if 'window' in layer:
            window = layer.pop('window')
        else:
            window = int(np.ceil(len(x) / 10.0))
        if 'level' in layer:
            level = layer.pop('level')
        else:
            level = 0.95
        if 'method' in layer:
            method = layer.pop('method')
        else:
            method = None

        idx = np.argsort(x)
        x = np.array(x)[idx]
        y = np.array(y)[idx]

        if method == "lm":
            y, y1, y2 = smoothers.lm(x, y, 1-level)
        elif method == "ma":
            y, y1, y2 = smoothers.mavg(x, y, window=window)
        else:
            y, y1, y2 = smoothers.lowess(x, y, span=span)
        plt.plot(x, y, **layer)
        if se==True:
            plt.fill_between(x, y1, y2, alpha=0.2, color="grey")
Beispiel #5
0
    def plot_layer(self, layer):
        layer = {k: v for k, v in layer.items() if k in self.VALID_AES}
        layer.update(self.manual_aes)

        if "x" in layer:
            x = layer.pop("x")
        if "y" in layer:
            y = layer.pop("y")
        if "se" in layer:
            se = layer.pop("se")
        else:
            se = None
        if "span" in layer:
            span = layer.pop("span")
        else:
            span = 2 / 3.0
        if "window" in layer:
            window = layer.pop("window")
        else:
            window = int(np.ceil(len(x) / 10.0))
        if "level" in layer:
            level = layer.pop("level")
        else:
            level = 0.95
        if "method" in layer:
            method = layer.pop("method")
        else:
            method = None

        idx = np.argsort(x)
        x = np.array(x)[idx]
        y = np.array(y)[idx]

        if method == "lm":
            y, y1, y2 = smoothers.lm(x, y, 1 - level)
        elif method == "ma":
            y, y1, y2 = smoothers.mavg(x, y, window=window)
        else:
            y, y1, y2 = smoothers.lowess(x, y, span=span)
        plt.plot(x, y, **layer)
        if se == True:
            plt.fill_between(x, y1, y2, alpha=0.2, color="grey")
Beispiel #6
0
    def plot_layer(self, layer):
        layer = dict((k, v) for k, v in layer.items() if k in self.VALID_AES)
        layer.update(self.manual_aes)

        if 'x' in layer:
            x = layer.pop('x')
        if 'y' in layer:
            y = layer.pop('y')
        if 'se' in layer:
            se = layer.pop('se')
        else:
            se = None
        if 'span' in layer:
            span = layer.pop('span')
        else:
            span = 2 / 3.
        if 'window' in layer:
            window = layer.pop('window')
        else:
            window = int(np.ceil(len(x) / 10.0))
        if 'level' in layer:
            level = layer.pop('level')
        else:
            level = 0.95
        if 'method' in layer:
            method = layer.pop('method')
        else:
            method = None

        idx = np.argsort(x)
        x = np.array(x)[idx]
        y = np.array(y)[idx]

        if method == "lm":
            y, y1, y2 = smoothers.lm(x, y, 1 - level)
        elif method == "ma":
            y, y1, y2 = smoothers.mavg(x, y, window=window)
        else:
            y, y1, y2 = smoothers.lowess(x, y, span=span)
        plt.plot(x, y, **layer)
        if se == True:
            plt.fill_between(x, y1, y2, alpha=0.2, color="grey")
Beispiel #7
0
    def _calculate(self, data):
        # sort data by x and
        # convert x and y to lists so that the Series index
        # does not mess with the smoothing functions
        data = data.sort(['x'])
        x = list(data.pop('x'))
        y = list(data.pop('y'))

        se = self.params['se']
        level = self.params['level']
        method = self.params['method']
        span = self.params['span']
        window = self.params['window']

        if window is None:
            window = int(np.ceil(len(x) / 10.0))

        # TODO: fix the smoothers
        #   - lm : y1, y2 are NaNs
        #   - mvg: investigate unexpected looking output
        if method == "lm":
            x, y, y1, y2 = smoothers.lm(x, y, 1-level)
        elif method == "ma":
            x, y, y1, y2 = smoothers.mavg(x, y, window=window)
        else:
            x, y, y1, y2 = smoothers.lowess(x, y, span=span)

        new_data = pd.DataFrame({'x': x, 'y': y})
        if se:
            new_data['ymin'] = y1
            new_data['ymax'] = y2

        # Copy the other aesthetics into the new dataframe
        n = len(x)
        for ae in data:
            new_data[ae] = make_iterable_ntimes(data[ae].iloc[0], n)
        return new_data
Beispiel #8
0
    def _calculate(self, data):
        # sort data by x and
        # convert x and y to lists so that the Series index
        # does not mess with the smoothing functions
        data = data.sort(['x'])
        x = list(data.pop('x'))
        y = list(data.pop('y'))

        se = self.params['se']
        level = self.params['level']
        method = self.params['method']
        span = self.params['span']
        window = self.params['window']

        if window is None:
            window = int(np.ceil(len(x) / 10.0))

        # TODO: fix the smoothers
        #   - lm : y1, y2 are NaNs
        #   - mvg: investigate unexpected looking output
        if method == "lm":
            x, y, y1, y2 = smoothers.lm(x, y, 1 - level)
        elif method == "ma":
            x, y, y1, y2 = smoothers.mavg(x, y, window=window)
        else:
            x, y, y1, y2 = smoothers.lowess(x, y, span=span)

        new_data = pd.DataFrame({'x': x, 'y': y})
        if se:
            new_data['ymin'] = y1
            new_data['ymax'] = y2

        # Copy the other aesthetics into the new dataframe
        n = len(x)
        for ae in data:
            new_data[ae] = make_iterable_ntimes(data[ae].iloc[0], n)
        return new_data