当前位置: 首页>>代码示例>>Python>>正文


Python seaborn.scatterplot方法代码示例

本文整理汇总了Python中seaborn.scatterplot方法的典型用法代码示例。如果您正苦于以下问题:Python seaborn.scatterplot方法的具体用法?Python seaborn.scatterplot怎么用?Python seaborn.scatterplot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在seaborn的用法示例。


在下文中一共展示了seaborn.scatterplot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_reddit_prop_plt

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def make_reddit_prop_plt():
    sns.set()
    prop_expt = pd.DataFrame(att.process_propensity_experiment())

    prop_expt = prop_expt[['exog', 'plugin', 'one_step_tmle', 'very_naive']]
    prop_expt = prop_expt.rename(index=str, columns={'exog': 'Exogeneity',
                                         'very_naive': 'Unadjusted',
                                         'plugin': 'Plug-in',
                                         'one_step_tmle': 'TMLE'})
    prop_expt = prop_expt.set_index('Exogeneity')

    plt.figure(figsize=(4.75, 3.00))
    # plt.figure(figsize=(2.37, 1.5))
    sns.scatterplot(data=prop_expt, legend='brief', s=75)
    plt.xlabel("Exogeneity", fontfamily='monospace')
    plt.ylabel("NDE Estimate", fontfamily='monospace')
    plt.tight_layout()

    fig_dir = '../output/figures'
    os.makedirs(fig_dir, exist_ok=True)
    plt.savefig(os.path.join(fig_dir,'reddit_propensity.pdf')) 
开发者ID:blei-lab,项目名称:causal-text-embeddings,代码行数:23,代码来源:prop_sim_plotting.py

示例2: noisy_adversary_opponent_subset_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def noisy_adversary_opponent_subset_plot(
    original_df, subset_specs, transform_specs, logistic=True, plot_line=True, savefile=None
):
    subset_df = subset(original_df, subset_specs)
    if len(subset_df) == 0:
        return
    transformed_df = transform(subset_df, transform_specs)
    plt.figure(figsize=(10, 7))
    if plot_line:
        sns.lmplot(data=transformed_df, x="log_noise", y="agent0_win_perc", logistic=logistic)
    else:
        sns.scatterplot(data=transformed_df, x="log_noise", y="agent0_win_perc")
    plt.title(
        "{}: Noisy Zoo{} Observations vs Adversary".format(
            subset_specs["env"], subset_specs["agent0_path"]
        )
    )
    if savefile is not None:
        plt.savefig(savefile)
    else:
        plt.show()
    plt.close() 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:24,代码来源:noisy_observations.py

示例3: scatter_plot_intent_dist

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def scatter_plot_intent_dist(workspace_pd):
    """
    takes the workspace_pd and generate a scatter distribution of the intents
    :param workspace_pd:
    :return:
    """

    label_frequency = Counter(workspace_pd["intent"]).most_common()
    frequencies = list(reversed(label_frequency))
    counter_list = list(range(1, len(frequencies) + 1))
    df = pd.DataFrame(data=frequencies, columns=["Intent", "Number of User Examples"])
    df["Intent"] = counter_list

    sns.set(rc={"figure.figsize": (15, 10)})
    display(
        Markdown(
            '## <p style="text-align: center;">Sorted Distribution of User Examples \
                     per Intent</p>'
        )
    )

    plt.ylabel("Number of User Examples", fontdict=LABEL_FONT)
    plt.xlabel("Intent", fontdict=LABEL_FONT)
    ax = sns.scatterplot(x="Intent", y="Number of User Examples", data=df, s=100) 
开发者ID:watson-developer-cloud,项目名称:assistant-dialog-skill-analysis,代码行数:26,代码来源:summary_generator.py

示例4: _plot_results_accuracy_comparison

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def _plot_results_accuracy_comparison(results_df, save_cfg):
    """Plot the comparison between the best model and best baseline.
    """
    fig, ax = plt.subplots(figsize=(save_cfg['text_width'], 
                                    save_cfg['text_height'] * 0.5))
    sns.scatterplot(data=results_df, x='Baseline (traditional)', y='Proposed', 
                    ax=ax)
    ax.plot([0, 1.1], [0, 1.1], c='k', alpha=0.2)
    plt.axis('square')
    ax.set_xlim([0, 1.1])
    ax.set_ylim([0, 1.1])
    plt.tight_layout()

    if save_cfg is not None:
        savename = 'reported_accuracy_comparison'
        fname = os.path.join(save_cfg['savepath'], savename)
        fig.savefig(fname + '.' + save_cfg['format'], **save_cfg)

    return ax 
开发者ID:hubertjb,项目名称:dl-eeg-review,代码行数:21,代码来源:analysis.py

示例5: plot_embeddings

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def plot_embeddings(self, embeddings):
        embeddings = MinMaxScaler((0, 1)).fit_transform(self.embeddings)

        fig = plt.figure()
        buf = io.BytesIO()
        sns.scatterplot(x=embeddings[:, 0], y=embeddings[:, 1], s=1,
                        hue=self.labels,
                        palette=sns.color_palette("hls", self.n_classes),
                        linewidth=0)

        plt.savefig(buf, format='png', dpi=300)
        plt.close(fig)
        buf.seek(0)

        image = tf.Summary.Image(encoded_image_string=buf.getvalue())
        return image 
开发者ID:beringresearch,项目名称:ivis,代码行数:18,代码来源:callbacks.py

示例6: plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def plot(x, y, plot_id, names=None):
    viz_df = pd.DataFrame(data=x[:5000])
    viz_df['Label'] = y[:5000]
    if names is not None:
        viz_df['Label'] = viz_df['Label'].map(names)

    viz_df.to_csv(args.save_dir + '/' + args.dataset + '.csv')
    plt.subplots(figsize=(8, 5))
    sns.scatterplot(x=0, y=1, hue='Label', legend='full', hue_order=sorted(viz_df['Label'].unique()),
                    palette=sns.color_palette("hls", n_colors=args.n_clusters),
                    alpha=.5,
                    data=viz_df)
    l = plt.legend(bbox_to_anchor=(-.1, 1.00, 1.1, .5), loc="lower left", markerfirst=True,
                   mode="expand", borderaxespad=0, ncol=args.n_clusters + 1, handletextpad=0.01, )

    l.texts[0].set_text("")
    plt.ylabel("")
    plt.xlabel("")
    plt.tight_layout()
    plt.savefig(args.save_dir + '/' + args.dataset +
                '-' + plot_id + '.png', dpi=300)
    plt.clf() 
开发者ID:rymc,项目名称:n2d,代码行数:24,代码来源:n2d.py

示例7: plot_2d

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def plot_2d(tsne, fnar, palette, outpng, verbose):
    """
    Create the 2d plot
    :param tsne: tSNE array
    :param fnar: functions list
    :param outpng: base name for pg output
    :return: nothing
    """
    
    if verbose:
        sys.stderr.write(f"{bcolors.GREEN}Plotting 2D tSNE{bcolors.ENDC}\n")

    snsplot = sns.scatterplot(tsne[:,0], tsne[:,1], legend="full", hue=fnar, palette=palette)
    plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
    plt.tight_layout()
    plt.savefig(outpng + ".png") 
开发者ID:linsalrob,项目名称:EdwardsLab,代码行数:18,代码来源:plot_phage_tsne.py

示例8: plot_2d_sz

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def plot_2d_sz(tsne, fnar, palette, outpng, verbose):
    """
    Create the 2d plot
    :param tsne: tSNE array
    :param fnar: functions list
    :param outpng: base name for pg output
    :return: nothing
    """
    
    if verbose:
        sys.stderr.write(f"{bcolors.GREEN}Plotting 2D tSNE by size{bcolors.ENDC}\n")

    sp = sns.scatterplot(x=tsne[:,0], y=tsne[:,1], s=tsne[:,2], legend="full", hue=fnar, palette=palette)
    plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
    plt.tight_layout()
    plt.savefig(outpng + ".sz.png") 
开发者ID:linsalrob,项目名称:EdwardsLab,代码行数:18,代码来源:plot_phage_tsne.py

示例9: plot_vs_ttest

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def plot_vs_ttest(self, log10=False):
        import matplotlib.pyplot as plt
        import seaborn as sns
        from .tests import t_test

        grouping = self.grouping
        ttest = t_test(
            data=self.x,
            grouping=grouping,
            gene_names=self.gene_ids,
        )
        if log10:
            ttest_pvals = ttest.log10_pval_clean()
            pvals = self.log10_pval_clean()
        else:
            ttest_pvals = ttest.pval
            pvals = self.pval

        fig, ax = plt.subplots()

        sns.scatterplot(x=ttest_pvals, y=pvals, ax=ax)

        ax.set(xlabel="t-test", ylabel='rank test')

        return fig, ax 
开发者ID:theislab,项目名称:diffxpy,代码行数:27,代码来源:det.py

示例10: finish

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def finish(self):
        dict = self.getDestinationItems()
        df = self.getDataFrame()

        try:
            x = dict['X Variable'][0]
            y = dict['Y Variable'][0]
            c = dict['Color By'][0]
        except IndexError:
            c = None

        sns.scatterplot(x, y, c, data=df)
        plt.show() 
开发者ID:adamerose,项目名称:pandasgui,代码行数:15,代码来源:dialogs.py

示例11: cluster_tsne

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def cluster_tsne(data, clusters, target, plot_name=None, **kwargs):
    """
    Plots TSNE projection of user stories colored by clusters. Each point represents a user session or whole user trajectory.

    Parameters
    --------
    data: pd.DataFrame
        Feature matrix.
    clusters: np.array
        Array of cluster IDs.
    target: np.array
        Boolean vector, if ``True``, then user has `positive_target_event` in trajectory.
    plot_name: str, optional
        Name of plot to save. Default: ``'clusters_tsne_{timestamp}.svg'``

    Returns
    -------
    Saves plot to ``retention_config.experiments_folder``

    Return type
    -------
    PNG
    """

    if hasattr(data.retention, '_tsne') and not kwargs.get('refit'):
        tsne2 = data.retention._tsne.copy()
    else:
        tsne2 = data.retention.learn_tsne(clusters, **kwargs)
    tsne = tsne2.values
    if np.unique(clusters).shape[0] > 10:
        f, ax = sns.mpl.pyplot.subplots()
        points = ax.scatter(tsne[:, 0], tsne[:, 1], c=clusters, cmap="BrBG")
        f.colorbar(points)
        scatter = ___FigureWrapper__(f)
    else:
        scatter = sns.scatterplot(tsne[:, 0], tsne[:, 1], hue=clusters, legend='full',
                                  palette=sns.color_palette("bright")[0:np.unique(clusters).shape[0]])
    plot_name = plot_name or 'cluster_tsne_{}'.format(datetime.now()).replace(':', '_').replace('.', '_') + '.svg'
    plot_name = data.retention.retention_config['experiments_folder'] + '/' + plot_name
    return scatter, plot_name, tsne2, data.retention.retention_config 
开发者ID:retentioneering,项目名称:retentioneering-tools,代码行数:42,代码来源:plot.py

示例12: plot_chemical_trajectory

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def plot_chemical_trajectory(self, environment, filename):
        """
        Plot the trajectory through chemical space.

        Parameters
        ----------
        environment : str
            the name of the environment for which the chemical space trajectory is desired
        """
        chemical_state_trajectory = self.extract_state_trajectory(environment)

        visited_states = list(set(chemical_state_trajectory))

        state_trajectory = np.zeros(len(chemical_state_trajectory))
        for idx, chemical_state in enumerate(chemical_state_trajectory):
            state_trajectory[idx] = visited_states.index(chemical_state)

        with PdfPages(filename) as pdf:
            sns.set(font_scale=2)
            fig = plt.figure(figsize=(28, 12))
            plt.subplot2grid((1,2), (0,0))
            ax = sns.scatterplot(np.arange(len(state_trajectory)), state_trajectory)
            plt.yticks(np.arange(len(visited_states)), visited_states)

            plt.title("Trajectory through chemical space in {}".format(environment))
            plt.xlabel("iteration")
            plt.ylabel("chemical state")
            plt.tight_layout()

            plt.subplot2grid((1,2), (0,1))
            ax = sns.countplot(y=state_trajectory)

            pdf.savefig(fig)
            plt.close() 
开发者ID:choderalab,项目名称:perses,代码行数:36,代码来源:analysis.py

示例13: create_scatterplot_from_df

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def create_scatterplot_from_df(
    df, x: str, y: str, output_path: str = ".", fig_x: int = 16, fig_y: int = 8
):
    """Loads an executive summary df and creates a scatterplot from some pre-specified variables.
    
    Args:
        df ([type]): [description]
        x (str): [description]
        y (str): [description]
        output_path (str, optional): [description]. Defaults to '.'.
        fig_x (int, optional): [description]. Defaults to 16.
        fig_y (int, optional): [description]. Defaults to 8.
    """
    if not os.path.exists(output_path):
        os.makedirs(output_path)
    # create graph dirs
    graph_dir = str(fig_x) + "_" + str(fig_y)
    out_dir = os.path.join(output_path, graph_dir)
    df[x] = df[x].astype(float)
    df[y] = df[y].astype(float)
    os.makedirs(out_dir, exist_ok=True)
    a4_dims = (14, 9)
    fig, ax = plt.subplots(figsize=a4_dims)
    graph = sns.scatterplot(
        ax=ax, x=x, y=y, data=df, s=325, alpha=0.5, hue="Experiment", legend="brief"
    )  # , palette="Set1")
    box = ax.get_position()
    plt.legend(markerscale=2)
    # ax.set_position([box.x0,box.y0,box.width*0.83,box.height])
    # plt.legend(loc='upper left',bbox_to_anchor=(1,1.15))
    # plt.ylim(bottom=0.0)

    # plt.legend(loc='lower right')
    # Use regplot to plot the regression line for the whole points
    # sns.regplot(x="FPOs", y=args.y_axis_var, data=df, sizes=(250, 500),  alpha=.5, scatter=False, ax=graph.axes[2])
    path_name = os.path.join(out_dir, "{}v{}.png".format(x, y))
    plt.savefig(path_name)
    plt.close("all")
    return path_name 
开发者ID:Breakend,项目名称:experiment-impact-tracker,代码行数:41,代码来源:create_graph_appendix.py

示例14: scatter_with_legend

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def scatter_with_legend(
        fig, ax, df, font_color, x, y, c, cmap, legend, **scatter_kwargs
):
    import seaborn as sns
    import matplotlib.patheffects as PathEffects

    unique_labels = np.unique(c)

    if legend == "on data":
        g = sns.scatterplot(
            x, y, hue=c, palette=cmap, ax=ax, legend=False, **scatter_kwargs
        )

        for i in unique_labels:
            color_cnt = np.nanmedian(df.iloc[np.where(c == i)[0], :2], 0)
            txt = ax.text(
                color_cnt[0],
                color_cnt[1],
                str(i),
                color=font_color,
                zorder=1000,
                verticalalignment="center",
                horizontalalignment="center",
                weight="bold",
            )  # c
            txt.set_path_effects(
                [
                    PathEffects.Stroke(
                        linewidth=1.5, foreground=font_color, alpha=0.8
                    ),  # 'w'
                    PathEffects.Normal(),
                ]
            )
    else:
        g = sns.scatterplot(
            x, y, hue=c, palette=cmap, ax=ax, legend="full", **scatter_kwargs
        )
        ax.legend(loc=legend, ncol=unique_labels // 15)

    return fig, ax 
开发者ID:aristoteleo,项目名称:dynamo-release,代码行数:42,代码来源:utils.py

示例15: visualize_distribution_static

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import scatterplot [as 别名]
def visualize_distribution_static(X,prediction,score, path=None):
    """
    Visualize the original distribution of the data in 2-dimension space, which outliers/inliers are colored as differnet scatter plot.

    Parameters
    ----------
    X: numpy array of shape (n_test, n_features)
        Test data.
    prediction: numpy array of shape (n_test, )
        The prediction result of the test data.
    score: umpy array of shape (n_test, )
        The outlier score of the test data.
    path: string
        The saving path for result figures.
    """
    sns.set(style="darkgrid")

    X=X.to_numpy()
    X_embedding = TSNE(n_components=2).fit_transform(X)

    outlier_label=[]
    for i in range(len(X_embedding)):
        if prediction[i]==1:
            outlier_label.append('inlier')
        else:
            outlier_label.append('outlier')
    X_outlier = pd.DataFrame({'x_emb':X_embedding[:,0],'y_emb':X_embedding[:,1],'outlier_label':np.array(outlier_label),'score':np.array(score)})
    new_sns = sns.scatterplot(x="x_emb", y="y_emb",hue = "score", sizes =20, palette = 'BuGn_r',legend = False, data = X_outlier)
    if path:
        new_sns.get_figure().savefig(path+'/distribution_withoutlier.png')
    plt.show() 
开发者ID:datamllab,项目名称:pyodds,代码行数:33,代码来源:plotUtils.py


注:本文中的seaborn.scatterplot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。