How to use the seaborn.distplot 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 edraizen / molmimic / molmimic / scratch / calc_voxel_resolution.py View on Github external
import seaborn as sns

    directory = "plots"

    try:
        os.makedirs(directory)
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise

    if density:
        densities = []
        for f in glob.glob("/data/draizene/molmimic/atom_densities/*_density.txt"):
            with open(f) as f_:
                densities.append(float(f_.read().rstrip()))
        sns.distplot(densities, hist=False, axlabel="Densities")
        plt.savefig(os.path.join(directory, "densities.pdf"))

    if collisions:
        collision_data = pd.DataFrame()
        for grid_size in xrange(25, 255, 5):
            grid_size /= 100.
            with open("/data/draizene/molmimic/atom_collisions/{}.txt".format(grid_size), "w") as out:
                for f in glob.glob("/data/draizene/molmimic/atom_collisions/*_collisions_{}.tsv".format(grid_size)):
                    with open(f) as f_:
                        for line in f_:
                            print >> out, line.rstrip().split("\t")[-1]
            print grid_size

        collision_data = pd.DataFrame()
        for grid_size in xrange(25, 255, 5):
            grid_size /= 100.
github Aqsa-K / Data-Visualization / VisualizeData.py View on Github external
#       category_column - column name in dataframe holding class labels
    #       graph_title - title to give to the graph plot

    # Plot:
    #       Using multiple Histograms
    #       Compare across the distributions easily

    fig = plt.figure(figsize=(6, 4))
    title = fig.suptitle(attribute + " - " + category_column, fontsize=14)
    fig.subplots_adjust(top=0.85, wspace=0.3)
    ax = fig.add_subplot(1, 1, 1)
    ax.set_xlabel(attribute)
    ax.set_ylabel("Frequency")

    g = sns.FacetGrid(dataf, hue=category_column)
    g.map(sns.distplot, attribute, kde=False, bins=15, ax=ax)
    ax.legend(title=category_column)

    plt.close(2)
    plt.show()
github puolival / multipy / multipy / viz.py View on Github external
def plot_pval_hist(pvals, hist_bins=1e2, show_plot=True):
    """Plot a simple density histogram of P-values.

    Input arguments:
    pvals      - The visualized P-values.
    hist_bins  - Number of histogram bins.
    """
    # Keep empty space at minimum.
    sns.set_style('darkgrid')
    fig = plt.figure(figsize=(6, 4))
    plt.subplots_adjust(top=0.925, bottom=0.125, left=0.105, right=0.950)

    """Plot the p-value density histogram for the whole data range."""
    ax1 = fig.add_subplot(111)
    sns.distplot(pvals, bins=hist_bins, rug=True, kde=False)

    """P-values are in the range [0, 1] so limit the drawing area
    accordingly. Label the axes etc."""
    ax1.set_xlim([-0.05, 1.05])
    ax1.set_xlabel('P-value')
    ax1.set_ylabel('Density')
    if (show_plot):
        plt.show()
    return fig
github cangermueller / deepcpg / scripts / dcpg_filter_motifs.py View on Github external
def plot_filter_densities(densities, filename=None):
    sns.set(font_scale=1.3)
    fig, ax = plt.subplots()
    sns.distplot(densities, kde=False, ax=ax)
    ax.set_xlabel('Activation')
    if filename:
        fig.savefig(filename)
        plt.close()
github gerazov / prosodeep / prosodeep / prosodeep_data.py View on Github external
for phone in textgrid.tiers[0]:  # tier 0 is the phones
            index += 1
            phone_durations.loc[index] = [phone.text, phone.duration()]
    print('')  # new line
    phone_durations = phone_durations.loc[:index]  # inclusive indexing in pandas
    phone_counts = phone_durations['phone'].value_counts()
    phone_duration_means = phone_durations.groupby('phone').mean()
    just_phones = phone_durations[~phone_durations.phone.isin(['_','__'])]
    phone_duration_total_mean = just_phones.duration.mean()
    phone_duration_total_median = just_phones.duration.median()

    #%% plot
    fig = plt.figure()
    sns.set(color_codes=False, style="white", context='paper')
    ax = sns.distplot(just_phones.duration)

    kde_x, kde_y = ax.get_lines()[0].get_data()
    phone_duration_total_kde = kde_x[np.argmax(kde_y)]
    plt.close(fig)

#    ax.axvline(phone_duration_total_mean, c='C1', lw=2, alpha=.7, label='mean')
#    ax.axvline(phone_duration_total_median, c='C2', lw=2, alpha=.7, label='median')
#    ax.axvline(phone_duration_total_kde, c='C4', lw=2, alpha=.7, label='kde')
#    ax.legend()
#    plt.title('Duration histogram for phones in {} \n mean = {} ms, median = {} ms, kde = {} ms'.format(
#                database, int(phone_duration_total_mean*1000), int(phone_duration_total_median*1000),
#                int(phone_duration_total_kde*1000)))
#    plt.xlabel('Duration')
#    plt.ylabel('Density')
#
github 1ytic / open_stt_e2e / data.py View on Github external
dataset = AudioDataset('data/', 'data/public_youtube700_val.csv', labels)

    loader = DataLoader(dataset, batch_size=32, collate_fn=collate_audio)

    x_lengths = []
    y_lengths = []

    for _, _, xn, yn in tqdm(loader):
        x_lengths.extend(list(xn.numpy()))
        y_lengths.extend(list(yn.numpy()))

    import seaborn as sns
    import matplotlib.pyplot as plt

    plt.title('x lengths')
    sns.distplot(x_lengths)
    plt.show()

    plt.title('y lengths')
    sns.distplot(y_lengths)
    plt.show()
github neale / HyperGAN / utils.py View on Github external
def plot_density_mnist(x_inliers, x_outliers, ens_size, prefix, epoch=0):
    in_entropy, in_variance = x_inliers
    out_entropy, out_variance = x_outliers
    f, axes = plt.subplots(2, 2, figsize=(22, 16))
    plt.suptitle('{} models MNIST'.format(ens_size))
    plt.subplots_adjust(top=0.85)

    sns.distplot(in_entropy, hist=False, label='MNIST', color='m', ax=axes[0,0])
    sns.distplot(out_entropy, hist=False, label='notMNIST', ax=axes[0,0])
    axes[0, 0].set_xlabel('Entropy')
    axes[0, 0].grid(True)

    sns.distplot(in_variance, hist=False, label='MNIST', color='m', ax=axes[0,1])
    sns.distplot(out_variance, hist=False, label='notMNIST', ax=axes[0,1])
    axes[0, 1].set_xlabel('Variance')
    axes[0, 1].grid(True)

    sns.distplot(out_entropy, hist=True, color='b', ax=axes[1, 0])
    axes[1, 0].set_xlabel('Entropy')
    axes[1, 0].set_title('notMNIST entropy')
    axes[1, 0].grid(True)

    sns.distplot(out_variance, hist=True, color='b', ax=axes[1, 1])
    axes[1, 1].set_xlabel('Variance')
    axes[1, 1].set_title('notMNIST variance')
github allenai / vampire / results / generate_figures.py View on Github external
def pdf_accuracy_over_throttle(self, throttle=200, save_path=None, show=True):
        if throttle not in self.throttles:
            raise Exception(f"throttle {throttle} is not available")
        fig, axis = self.initialize_figure((1, 1), (8, 6))
        classifiers = self.data.df.env_CLASSIFIER.unique()
        for classifier in classifiers:
            sub_df = self.data.df.loc[(self.data.df.env_CLASSIFIER == classifier) &
                                        (self.data.df.env_THROTTLE == throttle)]
            sns.distplot(sub_df.metric_best_validation_accuracy,
                         hist=False,
                         norm_hist=True,
                         label=classifier)
        axis.set_title("PDF of {} classification accuracy: {} training samples ({} trials across {} seeds)".format(self.data.dataset_name,
                                                                                                                   throttle,
                                                                                                                   sub_df.shape[0],
                                                                                                                   self.data.num_seeds))
        if show:
            plt.show()
        if save_path:
            self.save_figure(fig, save_path)
github LoLab-VU / PyDREAM / pydream / examples / necro_may2020 / calibrate_pydream_necro2.py View on Github external
if np.all(GR<1.2):
                converged = True

    try:
        #Plot output
        import seaborn as sns
        from matplotlib import pyplot as plt
        total_iterations = len(old_samples[0])
        burnin = total_iterations/2
        samples = np.concatenate(tuple([old_samples[i][int(burnin):, :] for i in range(nchains)]))

        ndims = len(sampled_params_list)
        colors = sns.color_palette(n_colors=ndims)
        for dim in range(ndims):
            fig = plt.figure()
            sns.distplot(samples[:, dim], color=colors[dim], norm_hist=True)
            fig.savefig('PyDREAM_necro5720_smallest_dimension_'+str(dim))

    except ImportError:
        pass

else:

    run_kwargs = {'parameters':sampled_params_list, 'likelihood':likelihood, 'niterations':niterations, 'nchains':nchains, \
                  'multitry':False, 'gamma_levels':4, 'adapt_gamma':True, 'history_thin':1, 'model_name':'necro_smallest_dreamzs5720_5chain', 'verbose':False}
github RJT1990 / pyflux / pyflux / arma / nnar.py View on Github external
if T == np.mean:
                description = " of the mean"
            elif T == np.max:
                description = " of the maximum"
            elif T == np.min:
                description = " of the minimum"
            elif T == np.median:
                description = " of the median"
            else:
                description = ""

            plt.figure(figsize=figsize)
            ax = plt.subplot()
            ax.axvline(T_actual)
            sns.distplot(T_sim, kde=False, ax=ax)
            ax.set(title='Posterior predictive' + description, xlabel='T(x)', ylabel='Frequency');
            plt.show()