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


Python seaborn.kdeplot方法代码示例

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


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

示例1: joint_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def joint_plot(x, y, xlabel=None,
               ylabel=None, xlim=None, ylim=None,
               loc="best", color='#0485d1',
               size=8, markersize=50, kind="kde",
               scatter_color="r"):
    with sns.axes_style("darkgrid"):
        if xlabel and ylabel:
            g = SubsampleJointGrid(xlabel, ylabel,
                    data=DataFrame(data={xlabel: x, ylabel: y}),
                    space=0.1, ratio=2, size=size, xlim=xlim, ylim=ylim)
        else:
            g = SubsampleJointGrid(x, y, size=size,
                    space=0.1, ratio=2, xlim=xlim, ylim=ylim)
        g.plot_joint(sns.kdeplot, shade=True, cmap="Blues")
        g.plot_sub_joint(plt.scatter, 1000, s=20, c=scatter_color, alpha=0.3)
        g.plot_marginals(sns.distplot, kde=False, rug=False)
        g.annotate(ss.pearsonr, fontsize=25, template="{stat} = {val:.2g}\np = {p:.2g}")
        g.ax_joint.set_yticklabels(g.ax_joint.get_yticks())
        g.ax_joint.set_xticklabels(g.ax_joint.get_xticks())
    return g 
开发者ID:Noahs-ARK,项目名称:idea_relations,代码行数:22,代码来源:plot_functions.py

示例2: astro_oligo_joint

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def astro_oligo_joint(X, genes, gene1, gene2, labels, focus, name):
    X = X.toarray()

    gidx1 = list(genes).index(gene1)
    gidx2 = list(genes).index(gene2)

    idx = labels == focus

    x1 = X[(idx, gidx1)]
    x2 = X[(idx, gidx2)]

    plt.figure()
    sns.jointplot(
        x1, x2, kind='scatter', space=0, alpha=0.3
    ).plot_joint(sns.kdeplot, zorder=0, n_levels=10)
    plt.savefig('{}_joint_{}_{}_{}.png'.format(name, focus, gene1, gene2)) 
开发者ID:brianhie,项目名称:geosketch,代码行数:18,代码来源:mouse_brain_subcluster.py

示例3: plot_activations

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def plot_activations(a_s,a_t,save_name):
    """
    activation visualization via seaborn library
    """
    n_dim=a_s.shape[1]
    n_rows=1
    n_cols=int(n_dim/n_rows)
    fig, axs = plt.subplots(nrows=n_rows,ncols=n_cols, sharey=True,
                            sharex=True)
    for k,ax in enumerate(axs.reshape(-1)):
        if k>=n_dim:
            continue
        sns.kdeplot(a_t[:,k],ax=ax, shade=True, label='target',
                    legend=False, color='0.4',bw=0.03)
        sns.kdeplot(a_s[:,k],ax=ax, shade=True, label='source',
                    legend=False, color='0',bw=0.03)
        plt.setp(ax.xaxis.get_ticklabels(),fontsize=10)
        plt.setp(ax.yaxis.get_ticklabels(),fontsize=10)
    fig.set_figheight(3)
    plt.setp(axs, xticks=[0, 0.5, 1])
    plt.setp(axs, ylim=[0,10])
    plt.savefig(save_name)


# load dataset 
开发者ID:wzell,项目名称:mann,代码行数:27,代码来源:artificial_example.py

示例4: plot_posterior

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def plot_posterior(model, variables, number_samples=1000):

    # Get samples
    sample = model.get_sample(number_samples)
    post_sample = model.get_posterior_sample(number_samples)

    # Join samples
    sample["Mode"] = "Prior"
    post_sample["Mode"] = "Posterior"
    subsample = sample[variables + ["Mode"]]
    post_subsample = post_sample[variables + ["Mode"]]
    joint_subsample = subsample.append(post_subsample)

    # Plot posterior
    warnings.filterwarnings('ignore')
    g = sns.PairGrid(joint_subsample, hue="Mode")
    g = g.map_offdiag(sns.kdeplot)
    g = g.map_diag(sns.kdeplot, lw=3, shade=True)
    g = g.add_legend()
    warnings.filterwarnings('default') 
开发者ID:AI-DI,项目名称:Brancher,代码行数:22,代码来源:visualizations.py

示例5: plotCorrelation

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def plotCorrelation(stats):
    #columnsToDrop = ['sleep_interval_max_len', 'sleep_interval_min_len',
    #                 'sleep_interval_avg_len', 'sleep_inefficiency',
    #                 'sleep_hours', 'total_hours']

    #stats = stats.drop(columnsToDrop, axis=1)

    g = sns.PairGrid(stats)
    def corrfunc(x, y, **kws):
        r, p = scipystats.pearsonr(x, y)
        ax = plt.gca()
        ax.annotate("r = {:.2f}".format(r),xy=(.1, .9), xycoords=ax.transAxes)
        ax.annotate("p = {:.2f}".format(p),xy=(.2, .8), xycoords=ax.transAxes)
        if p>0.04:
            ax.patch.set_alpha(0.1)

    g.map_upper(plt.scatter)
    g.map_diag(plt.hist)
    g.map_lower(sns.kdeplot, cmap="Blues_d")
    g.map_upper(corrfunc)
    sns.plt.show() 
开发者ID:5agado,项目名称:fitbit-analyzer,代码行数:23,代码来源:plotting.py

示例6: comparative_densities

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def comparative_densities(
    env, victim_id, n_components, covariance, cutoff_point=None, savefile=None, **kwargs
):
    """PDF of different opponents density distribution.
    For unspecified parameters, see get_full_directory.

    :param cutoff_point: (float): left x-limit.
    :param savefile: (None or str) path to save figure to.
    :param kwargs: (dict) passed through to sns.kdeplot."""
    df = load_metadata(env, victim_id, n_components, covariance)
    fig = plt.figure(figsize=(10, 7))

    grped = df.groupby("opponent_id")
    for name, grp in grped:
        # clean up random_none to just random
        name = name.replace("_none", "")
        avg_log_proba = np.mean(grp["log_proba"])
        sns.kdeplot(grp["log_proba"], label=f"{name}: {round(avg_log_proba, 2)}", **kwargs)

    xmin, xmax = plt.xlim()
    xmin = max(xmin, cutoff_point)
    plt.xlim((xmin, xmax))

    plt.suptitle(f"{env} Densities, Victim Zoo {victim_id}: Trained on Zoo 1", y=0.95)
    plt.title("Avg Log Proba* in Legend")

    if savefile is not None:
        fig.savefig(f"{savefile}.pdf") 
开发者ID:HumanCompatibleAI,项目名称:adversarial-policies,代码行数:30,代码来源:visualize.py

示例7: plot_nn_dist_distr

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def plot_nn_dist_distr(params):
    """
    Plot distributions of nearest neighbor distances
    """
    import matplotlib.pyplot as plt
    import seaborn as sns

    split_set, aa_dist, ii_dist, ai_dist, ia_dist, thresholds = params[:]
    vaI, viI, taI, tiI = split_set
    
    # get the slices of the distance matrices
    aTest_aTrain_D = aa_dist[ np.ix_( vaI, taI ) ]
    aTest_iTrain_D = ai_dist[ np.ix_( vaI, tiI ) ]
    iTest_aTrain_D = ia_dist[ np.ix_( viI, taI ) ] 
    iTest_iTrain_D = ii_dist[ np.ix_( viI, tiI ) ]

    aa_nn_dist = np.min(aTest_aTrain_D, axis=1)
    ai_nn_dist = np.min(aTest_iTrain_D, axis=1)
    ia_nn_dist = np.min(iTest_aTrain_D, axis=1)
    ii_nn_dist = np.min(iTest_iTrain_D, axis=1)

    # Plot distributions of nearest-neighbor distances
    fig, axes = plt.subplots(2, 2, figsize=(12,12))
    sns.kdeplot(aa_nn_dist, ax=axes[0,0])
    axes[0,0].set_title('AA')
    sns.kdeplot(ai_nn_dist, ax=axes[0,1])
    axes[0,1].set_title('AI')
    sns.kdeplot(ia_nn_dist, ax=axes[1,0])
    axes[1,0].set_title('II')
    sns.kdeplot(ii_nn_dist, ax=axes[1,1])
    axes[1,1].set_title('IA')

#******************************************************************************************************************************************* 
开发者ID:ATOMconsortium,项目名称:AMPL,代码行数:35,代码来源:ave_splitter.py

示例8: plot_density

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def plot_density(model, variables, number_samples=2000):
    sample = model.get_sample(number_samples)
    warnings.filterwarnings('ignore')
    g = sns.PairGrid(sample[variables])
    g = g.map_offdiag(sns.kdeplot)
    g = g.map_diag(sns.kdeplot, lw=3, shade=True)
    g = g.add_legend()
    warnings.filterwarnings('default') 
开发者ID:AI-DI,项目名称:Brancher,代码行数:10,代码来源:visualizations.py

示例9: _joint_grid

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def _joint_grid(col_x, col_y, col_k, df, k_is_color=False, scatter_alpha=.85):

    def colored_kde(x, y, c=None):
        def kde(*args, **kwargs):
             args = (x, y)
             if c is not None:
                 kwargs['c'] = c
             kwargs['alpha'] = scatter_alpha
             sns.kdeplot(*args, **kwargs)
        return kde

    g = sns.JointGrid(
        x=col_x,
        y=col_y,
        data=df
    )
    color = None
    legends = []
    for name, df_group in df.groupby(col_k):
        legends.append(name)
        if k_is_color:
            color=name
        g.plot_joint(
            colored_kde(df_group[col_x], df_group[col_y], color),
        )
        sns.kdeplot(
            df_group[col_x].values,
            ax=g.ax_marg_x,
            color=color,
            shade=True
        )
        sns.kdeplot(
            df_group[col_y].values,
            ax=g.ax_marg_y,
            color=color,
            shade=True,
            vertical=True
        )
    plt.legend(legends) 
开发者ID:AI-DI,项目名称:Brancher,代码行数:41,代码来源:visualizations.py

示例10: plot_breakpoints_hist

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def plot_breakpoints_hist(v1, v2, v1_name, v2_name):
    sns.kdeplot(v1, color="b", label=v1_name, shade=True, legend=False)
    sns.kdeplot(v2, color="r", label=v2_name, shade=True, legend=False)
    pyplot.legend(loc="upper right") 
开发者ID:tskit-dev,项目名称:msprime,代码行数:6,代码来源:verification.py

示例11: plot_tensor

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
开发者ID:hossein1387,项目名称:U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation,代码行数:15,代码来源:model_visualizer.py

示例12: _plot_kde

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import kdeplot [as 别名]
def _plot_kde(output_res, pick_rows, color_palette, alpha=0.5):
    num_clusters = len(set(pick_rows))
    for ci in range(num_clusters):
        cur_plot_rows = pick_rows == ci
        cur_cmap = sns.light_palette(color_palette[ci], as_cmap=True)
        sns.kdeplot(output_res[cur_plot_rows, 0], output_res[cur_plot_rows, 1], cmap=cur_cmap, shade=True, alpha=alpha,
            shade_lowest=False)
        centroid = output_res[cur_plot_rows, :].mean(axis=0)
        plt.annotate('%s' % ci, xy=centroid, xycoords='data', alpha=0.5,
                     horizontalalignment='center', verticalalignment='center') 
开发者ID:jsilter,项目名称:parametric_tsne,代码行数:12,代码来源:example_viz_parametric_tSNE.py


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