How to use the seaborn.lineplot function in seaborn

To help you get started, we’ve selected a few seaborn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shawnLeeZX / akid / tests / test_ops.py View on Github external
# A PSD matrix can be created as follows, though is not used in the test.
        # H = H @ H.t()
        eigenvalues = A.symeig(H)[0]
        spectrum_norm = A.max(eigenvalues)
        H /= spectrum_norm

        K = 1024
        n_vec = 1
        eigs = matrix_ops.lanczos_spectrum_approx(H, 100, K, n_vec)
        eig_ref = A.symeig(H)[0]
        import seaborn as sns
        from matplotlib import pyplot as plt
        import pandas as pd
        plt.figure()
        sns.distplot(A.eval(eig_ref), bins=50, norm_hist=True, kde=False)
        sns.lineplot(data=pd.DataFrame(A.eval(eigs), index=np.linspace(-1, 1, K)) )
        plt.savefig("lanczos_wigner.jpg")
github vlajnaya-mol / message-analyser / message_analyser / plotter.py View on Github external
def lineplot_message_length(msgs, your_name, target_name, path_to_save):
    sns.set(style="whitegrid")

    (x, y_total), (xticks, xticks_labels, xlabel) = _get_plot_data(msgs), _get_xticks(msgs)

    y_your = [avg([len(msg.text) for msg in period if msg.author == your_name]) for period in y_total]
    y_target = [avg([len(msg.text) for msg in period if msg.author == target_name]) for period in y_total]

    plt.fill_between(x, y_your, alpha=0.3)
    ax = sns.lineplot(x=x, y=y_your, palette="denim blue", linewidth=2.5, label=your_name)
    plt.fill_between(x, y_target, alpha=0.3)
    sns.lineplot(x=x, y=y_target, linewidth=2.5, label=target_name)

    ax.set(xlabel=xlabel, ylabel="average message length (characters)")
    ax.set_xticklabels(xticks_labels)

    ax.tick_params(axis='x', bottom=True, color="#A9A9A9")
    plt.xticks(xticks, rotation=65)
    ax.margins(x=0, y=0)

    # plt.tight_layout()
    fig = plt.gcf()
    fig.set_size_inches(13, 7)

    fig.savefig(os.path.join(path_to_save, lineplot_message_length.__name__ + ".png"), dpi=500)
    # plt.show()
    plt.close("all")
    log_line(f"{lineplot_message_length.__name__} was created.")
github theislab / dca / dca / utils.py View on Github external
m = ad.X.mean(axis=0)
    v = ad.X.var(axis=0)

    coefs, r2 = _fitquad(m, v)

    ax.set(xscale="log", yscale="log")
    ax.plot(m, v, 'o', c='black', markersize=1)

    poly = np.poly1d(coefs)
    sns.lineplot(m, poly(m), ax=ax, color='red')

    ax.set_title(title)
    ax.set_ylabel('Variance')
    ax.set_xlabel(r'$\mu$')

    sns.lineplot(m, m, ax=ax, color='blue')
    ax.legend(['Genes', r'NB ($\theta=%.2f)\ r^2=%.3f$' % (coefs[0], r2), 'Poisson'])

    return coefs[0]
github kashif / firedup / fireup / utils / plot.py View on Github external
smooth data with moving window average.
        that is,
            smoothed_y[t] = average(y[t-k], y[t-k+1], ..., y[t+k-1], y[t+k])
        where the "smooth" param is width of that window (2k+1)
        """
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x, y, "same") / np.convolve(z, y, "same")
            datum[value] = smoothed_x

    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.5)
    sns.lineplot(data=data, x=xaxis, y=value, hue=condition, ci="sd", **kwargs)
    plt.legend(
        loc="upper center", ncol=3, handlelength=1, borderaxespad=0.0, prop={"size": 13}
    ).set_draggable(True)

    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        # Just some formatting niceness: x-axis scale in scientific notation if max x is large
        plt.ticklabel_format(style="sci", axis="x", scilimits=(0, 0))

    plt.tight_layout(pad=0.5)
github ContextLab / quail / quail / plot.py View on Github external
def plot_spc(data, plot_style, plot_type, listname, subjname, **kwargs):

        plot_type = plot_type if plot_type is not None else 'list'

        if plot_type is 'subject':
            ax = sns.lineplot(data = data, x="Position", y="Proportion Recalled", hue=subjname, **kwargs)
        elif plot_type is 'list':
            ax = sns.lineplot(data = data, x="Position", y="Proportion Recalled", hue=listname, **kwargs)
        ax.set_xlim(0, data['Position'].max())

        return ax
github vlajnaya-mol / message-analyser / message_analyser / plotter.py View on Github external
def lineplot_messages(msgs, your_name, target_name, path_to_save):
    sns.set(style="whitegrid")

    (x, y_total), (xticks, xticks_labels, xlabel) = _get_plot_data(msgs), _get_xticks(msgs)

    y_your = [len([msg for msg in period if msg.author == your_name]) for period in y_total]
    y_target = [len([msg for msg in period if msg.author == target_name]) for period in y_total]

    plt.fill_between(x, y_your, alpha=0.3)
    ax = sns.lineplot(x=x, y=y_your, palette="denim blue", linewidth=2.5, label=your_name)
    plt.fill_between(x, y_target, alpha=0.3)
    sns.lineplot(x=x, y=y_target, linewidth=2.5, label=target_name)

    ax.set(xlabel=xlabel, ylabel="messages")
    ax.set_xticklabels(xticks_labels)

    ax.tick_params(axis='x', bottom=True, color="#A9A9A9")
    plt.xticks(xticks, rotation=65)
    ax.margins(x=0, y=0)

    # plt.tight_layout()
    fig = plt.gcf()
    fig.set_size_inches(13, 7)

    fig.savefig(os.path.join(path_to_save, lineplot_messages.__name__ + ".png"), dpi=500)
    # plt.show()
    plt.close("all")
    log_line(f"{lineplot_messages.__name__} was created.")
github datamllab / pyodds / pyodds / utils / plotUtils.py View on Github external
Parameters
    ----------
    ts: numpy array of shape (n_test, n_features)
        The value of the test time serie data.
    value: numpy array of shape (n_test, )
        The outlier score of the test data.
    path: string
        The saving path for result figures.
    """
    sns.set(style="ticks")

    ts = pd.DatetimeIndex(ts)
    value=value.to_numpy()[:,1:]
    data = pd.DataFrame(value,ts)
    data = data.rolling(2).mean()
    sns_plot=sns.lineplot(data=data, palette="BuGn_r", linewidth=0.5)
    if path:
        sns_plot.figure.savefig(path+'/timeserie.png')
    plt.show()
github xlnwel / model-free-algorithms / utility / plot.py View on Github external
def plot_data(data, x, y, outdir, tag, title, timing=None):
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
        if timing:
            data = data[data.Timing == timing].drop('Timing', axis=1)

    if not os.path.isdir(outdir):
        os.mkdir(outdir)
    fig = plt.figure(figsize=(20, 10))
    ax = fig.add_subplot(111)
    sns.set(style="whitegrid", font_scale=1.5)
    sns.set_palette('Set2') # or husl
    if 'Timing' in data.columns:
        sns.lineplot(x=x, y=y, ax=ax, data=data, hue=tag, style='Timing')
    else:
        sns.lineplot(x=x, y=y, ax=ax, data=data, hue=tag)
    ax.grid(True, alpha=0.8, linestyle=':')
    ax.legend(loc='best').set_draggable(True)
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)
    if timing:
        title = f'{title}-{timing}'
    outpath = f'{outdir}/{title}.png'
    ax.set_title(title)
    fig.savefig(outpath)
    pwc(f'Plot Path: {outpath}')
github dcgym / iroko / plot.py View on Github external
marker_range = list(np.arange(
        math.ceil(sample / 10), sample, math.ceil(sample / 10)))
    for index, metric in enumerate(plt_metrics):
        metric_df = metrics[metric]
        log.info("Drop overlimit rows %s." % metric)
        metric_df = metric_df.drop(metric_df.index[num_samples:])
        log.info("Computing rolling %s." % metric)
        metric_df = compute_rolling_df_mean(metric_df, mean_smoothing)
        log.info("Normalizing %s." % metric)
        metric_df = normalize_df_min_max(metric_df)
        log.info("Plotting %s..." % metric)
        if index == 0:
            plt_legend = "brief"
        else:
            plt_legend = False
        ax[index] = sns.lineplot(data=metric_df,
                                 ax=ax[index], legend=plt_legend,
                                 markers=True, markevery=marker_range,
                                 style="event")
        ax[index].set_ylabel(metric)
        if index == num_subplots - 1:
            ax[index].set_xlabel("Time")
        ax[index].set_xlim([0, num_samples])
        ax[index].margins(y=0.15)
    ax[0].legend(bbox_to_anchor=(0.5, 1.45), loc="upper center",
                 fancybox=True, shadow=True, ncol=len(algos))
    log.info("Saving plot %s" % plt_name)
    plt.savefig(plt_name + ".pdf", bbox_inches='tight', pad_inches=0.05)
    plt.savefig(plt_name + ".png", bbox_inches='tight', pad_inches=0.05)
    plt.gcf().clear()
github stefmolin / stock-analysis / stock_analysis / stock_visualizer.py View on Github external
"""
        Visualize the evolution over time of a column for all assets in group.

        Parameters:
            - column: The name of the column to visualize.
            - kwargs: Additional keyword arguments to pass down
                      to the plotting function.

        Returns:
            A matplotlib Axes object.
        """
        if 'ax' not in kwargs:
            fig, ax = plt.subplots(1, 1, figsize=(10, 4))
        else:
            ax = kwargs.pop('ax')
        return sns.lineplot(
            x=self.data.index,
            y=column,
            hue=self.group_by,
            data=self.data,
            ax=ax,
            **kwargs
        )