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


Python seaborn.distplot方法代码示例

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


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

示例1: plot_binarization

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def plot_binarization(auc_mtx: pd.DataFrame, regulon_name: str, threshold: float, bins: int=200, ax=None) -> None:
    """
    Plot the "binarization" process for the given regulon.

    :param auc_mtx: The dataframe with the AUC values for all cells and regulons (n_cells x n_regulons).
    :param regulon_name: The name of the regulon.
    :param bins: The number of bins to use in the AUC histogram.
    :param threshold: The threshold to use for binarization.
    """
    if ax is None:
        ax=plt.gca()
    sns.distplot(auc_mtx[regulon_name], ax=ax, norm_hist=True, bins=bins)

    ylim = ax.get_ylim()
    ax.plot([threshold]*2, ylim, 'r:')
    ax.set_ylim(ylim)
    ax.set_xlabel('AUC')
    ax.set_ylabel('#')
    ax.set_title(regulon_name) 
开发者ID:aertslab,项目名称:pySCENIC,代码行数:21,代码来源:plotting.py

示例2: joint_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [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

示例3: distplot_messages_per_hour

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def distplot_messages_per_hour(msgs, path_to_save):
    sns.set(style="whitegrid")

    ax = sns.distplot([msg.date.hour for msg in msgs], bins=range(25), color="m", kde=False)
    ax.set_xticklabels(stools.get_hours())
    ax.set(xlabel="hour", ylabel="messages")
    ax.margins(x=0)

    plt.xticks(range(24), rotation=65)
    plt.tight_layout()
    fig = plt.gcf()
    fig.set_size_inches(11, 8)

    fig.savefig(os.path.join(path_to_save, distplot_messages_per_hour.__name__ + ".png"), dpi=500)
    # plt.show()
    log_line(f"{distplot_messages_per_hour.__name__} was created.")
    plt.close("all") 
开发者ID:vlajnaya-mol,项目名称:message-analyser,代码行数:19,代码来源:plotter.py

示例4: distplot_messages_per_day

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def distplot_messages_per_day(msgs, path_to_save):
    sns.set(style="whitegrid")

    data = stools.get_messages_per_day(msgs)

    max_day_len = len(max(data.values(), key=len))
    ax = sns.distplot([len(day) for day in data.values()], bins=list(range(0, max_day_len, 50)) + [max_day_len],
                      color="m", kde=False)
    ax.set(xlabel="messages", ylabel="days")
    ax.margins(x=0)

    fig = plt.gcf()
    fig.set_size_inches(11, 8)

    fig.savefig(os.path.join(path_to_save, distplot_messages_per_day.__name__ + ".png"), dpi=500)
    # plt.show()
    log_line(f"{distplot_messages_per_day.__name__} was created.")
    plt.close("all") 
开发者ID:vlajnaya-mol,项目名称:message-analyser,代码行数:20,代码来源:plotter.py

示例5: distplot_messages_per_month

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def distplot_messages_per_month(msgs, path_to_save):
    sns.set(style="whitegrid")

    start_date = msgs[0].date.date()
    (xticks, xticks_labels, xlabel) = _get_xticks(msgs)

    ax = sns.distplot([(msg.date.date() - start_date).days for msg in msgs],
                      bins=xticks + [(msgs[-1].date.date() - start_date).days], color="m", kde=False)
    ax.set_xticklabels(xticks_labels)
    ax.set(xlabel=xlabel, ylabel="messages")
    ax.margins(x=0)

    plt.xticks(xticks, rotation=65)
    plt.tight_layout()
    fig = plt.gcf()
    fig.set_size_inches(11, 8)

    fig.savefig(os.path.join(path_to_save, distplot_messages_per_month.__name__ + ".png"), dpi=500)
    # plt.show()
    log_line(f"{distplot_messages_per_month.__name__} was created.")
    plt.close("all") 
开发者ID:vlajnaya-mol,项目名称:message-analyser,代码行数:23,代码来源:plotter.py

示例6: plot_mean_bootstrap_exponential_readme

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def plot_mean_bootstrap_exponential_readme():
    X = np.random.exponential(7, 4)
    classical_samples = [np.mean(resample(X)) for _ in range(10000)]
    posterior_samples = mean(X, 10000)
    l, r = highest_density_interval(posterior_samples)
    classical_l, classical_r = highest_density_interval(classical_samples)
    plt.subplot(2, 1, 1)
    plt.title('Bayesian Bootstrap of mean')
    sns.distplot(posterior_samples, label='Bayesian Bootstrap Samples')
    plt.plot([l, r], [0, 0], linewidth=5.0, marker='o', label='95% HDI')
    plt.xlim(-1, 18)
    plt.legend()
    plt.subplot(2, 1, 2)
    plt.title('Classical Bootstrap of mean')
    sns.distplot(classical_samples, label='Classical Bootstrap Samples')
    plt.plot([classical_l, classical_r], [0, 0], linewidth=5.0, marker='o', label='95% HDI')
    plt.xlim(-1, 18)
    plt.legend()
    plt.savefig('readme_exponential.png', bbox_inches='tight') 
开发者ID:lmc2179,项目名称:bayesian_bootstrap,代码行数:21,代码来源:demos.py

示例7: histogram

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def histogram(self, column, **kwargs):
        """
        Generate the histogram of a given 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.
        """
        fig, axes = self._get_layout()
        for ax, (name, data) in zip(axes, self.data.groupby(self.group_by)):
            sns.distplot(data[column], ax=ax, axlabel=f'{name} - {column}')
        return axes 
开发者ID:stefmolin,项目名称:stock-analysis,代码行数:18,代码来源:stock_visualizer.py

示例8: export_animation

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def export_animation(anim_frames):
    i = 0
    for t_data, g_data in anim_frames:
        f, ax = plt.subplots(figsize=(12, 8))
        f.suptitle('Generative Adversarial Network', fontsize=15)
        plt.xlabel('Data values')
        plt.ylabel('Probability density')
        ax.set_xlim(-2, 10)
        ax.set_ylim(0, 1.2)
        sns.distplot(t_data, hist=False, rug=True, color='r', label='Target Data', ax=ax)
        sns.distplot(g_data, hist=False, rug=True, color='g', label='Generated Data', ax=ax)
        f.savefig("images/frame_" + str(i) + ".png")
        print "Frame index: ", i * SAMPLE_RATE
        f.clf()
        plt.close()
        i += 1

# Generate mp4 from images:
# avconv -r 10 -i frame_%d.png -b:v 1000k gan.mp4
# convert -delay 20 -loop 0 output/decision_*.png myimage.gif 
开发者ID:mengli,项目名称:MachineLearning,代码行数:22,代码来源:gan.py

示例9: _plot_results_accuracy_diff_distr

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def _plot_results_accuracy_diff_distr(results_df, save_cfg):
    """Plot the distribution of difference in accuracy.
    """
    fig, ax = plt.subplots(figsize=(save_cfg['text_width'], 
                                    save_cfg['text_height'] * 0.5))
    sns.distplot(results_df['acc_diff'], kde=False, rug=True, ax=ax)
    ax.set_xlabel('Accuracy difference')
    ax.set_ylabel('Number of studies')
    plt.tight_layout()

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

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

示例10: plot_number_channels

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def plot_number_channels(df, save_cfg=cfg.saving_config):
    """Plot histogram of number of channels.
    """
    nb_channels_df = ut.split_column_with_multiple_entries(
        df, 'Nb Channels', ref_col='Citation', sep=';\n', lower=False)
    nb_channels_df['Nb Channels'] = nb_channels_df['Nb Channels'].astype(int)
    nb_channels_df = nb_channels_df.loc[nb_channels_df['Nb Channels'] > 0, :]

    fig, ax = plt.subplots(
        figsize=(save_cfg['text_width'] / 2, save_cfg['text_height'] / 4))
    sns.distplot(nb_channels_df['Nb Channels'], kde=False, norm_hist=False, ax=ax)
    ax.set_xlabel('Number of EEG channels')
    ax.set_ylabel('Number of papers')

    logger.info('Stats on number of channels per model: {}'.format(
        nb_channels_df['Nb Channels'].describe()))

    plt.tight_layout()

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

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

示例11: draw_dist_plots_summary_cols

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def draw_dist_plots_summary_cols(df_train, target, summary_cols):
    colors = cycle('byrcmgkbyrcmgkbyrcmgkbyrcmgkbyr')
    target_names = np.unique(df_train[target])
    ncols =2
    nrows = int((len(summary_cols)/2)+0.50)
    fig, axes = plt.subplots(ncols=ncols, nrows=nrows, figsize=(20,nrows*6), dpi=100)
    axs = []
    for i in range(nrows):
        for j in range(ncols):
            axs.append('axes['+str(i)+','+str(j)+']')
    labels = []
    for axi, feature in enumerate(summary_cols):
        for target_name in target_names:
            label = str(target_name)
            color = next(colors)
            sns.distplot(df_train.loc[df_train[target] == target_name][feature],
                         label=label,
                     ax=eval(axs[axi]), color=color, kde_kws={'bw':1.5})
            labels.append(label)
    plt.legend(labels=labels)
    plt.show();
############################################################################# 
开发者ID:AutoViML,项目名称:Auto_ViML,代码行数:24,代码来源:Auto_NLP.py

示例12: plot_posterior_histogram

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def plot_posterior_histogram(model, variables, number_samples=300): #TODO: fix code duplication

    # 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.distplot)
    g = g.map_diag(sns.distplot)
    g = g.add_legend()
    warnings.filterwarnings('default') 
开发者ID:AI-DI,项目名称:Brancher,代码行数:22,代码来源:visualizations.py

示例13: disp_gap_bydate

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def disp_gap_bydate(self):
        gaps_mean = self.gapdf.groupby('time_date')['gap'].mean()
        gaps_mean.plot(kind='bar')
        plt.ylabel('Mean of gap')
        plt.title('Date/Gap Correlation')
#         for i in gaps_mean.index:
#             plt.plot([i,i], [0, gaps_mean[i]], 'k-')
        plt.show()
        return
   
#     def drawGapDistribution(self):
#         self.gapdf[self.gapdf['gapdf'] < 10]['gapdf'].hist(bins=50)
# #         sns.distplot(self.gapdf['gapdf']);
# #         sns.distplot(self.gapdf['gapdf'], hist=True, kde=False, rug=False)
# #         plt.hist(self.gapdf['gapdf'])
#         plt.show()
#         return
#     def drawGapCorrelation(self):
#         _, (ax1, ax2) = plt.subplots(nrows=2, ncols=1)
#         res = self.gapdf.groupby('start_district_id')['gapdf'].sum()
#         ax1.bar(res.index, res.values)
#         res = self.gapdf.groupby('time_slotid')['gapdf'].sum()
#         ax2.bar(res.index.map(lambda x: x[11:]), res.values)
#         plt.show()
#         return 
开发者ID:LevinJ,项目名称:Supply-demand-forecasting,代码行数:27,代码来源:visualization.py

示例14: traffic_districution

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def traffic_districution(self):
        data_dir = g_singletonDataFilePath.getTrainDir()
        df = self.load_trafficdf(data_dir)
        print df['traffic'].describe()
#         sns.distplot(self.gapdf['gap'],kde=False, bins=100);
        df['traffic'].plot(kind='hist', bins=100)
        plt.xlabel('Traffic')
        plt.title('Histogram of Traffic')

        return
#     def disp_gap_bydistrict(self, disp_ids = np.arange(34,67,1), cls1 = 'start_district_id', cls2 = 'time_id'):
# #         disp_ids = np.arange(1,34,1)
#         plt.figure()
#         by_district = self.gapdf.groupby(cls1)
#         size = len(disp_ids)
# #         size = len(by_district)
#         col_len = row_len = math.ceil(math.sqrt(size))
#         count = 1
#         for name, group in by_district:
#             if not name in disp_ids:
#                 continue
#             plt.subplot(row_len, col_len, count)
#             group.groupby(cls2)['gap'].mean().plot()
#             count += 1   
#         return 
开发者ID:LevinJ,项目名称:Supply-demand-forecasting,代码行数:27,代码来源:visualize_traindata.py

示例15: plot_target_distribution

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import distplot [as 别名]
def plot_target_distribution(y_test, cfg):
    if 'xml_path' in cfg['dataset']:
        basename = os.path.basename(cfg['dataset']['xml_path'])
        patient_id = basename.split('-')[0]
    else:
        patient_id = ""
    if 'scale' in cfg['dataset']:
        scale = float(cfg['dataset']['scale'])
    else:
        scale = 1.0

    plt.figure()
    sns.distplot(y_test.flatten()/scale, kde=False, norm_hist=True)
    save_path = os.path.join(cfg['train']['artifacts_path'], "{}_dist_plot.pdf".format(patient_id))
    print("saving plot to: ", save_path)
    plt.savefig(save_path, dpi=300) 
开发者ID:johnmartinsson,项目名称:blood-glucose-prediction,代码行数:18,代码来源:run.py


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