How to use the seaborn.despine 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 mogoweb / aiexamples / AIDog / tflite / scripts / stats.py View on Github external
print('Top 3 分类正确率:%f' % (np.sum(df['accuracy3']) / len(df)))

# 每种狗狗分类正确率
accuracies = df.groupby('label')['accuracy'].sum() / df.groupby('label')['accuracy'].count()
accuracies.sort_values(inplace=True)
print('正确率后五:')
for i in range(5):
	print('-', accuracies.index[i], accuracies[i])
print('正确率前五:')
for i in range(5):
	print('-', accuracies.index[len(accuracies) - 1 - i], accuracies[len(accuracies) - 1 - i])
plt.figure(figsize=(6, 6))
sns.barplot(accuracies.values, accuracies.index)
plt.yticks([])
plt.ylabel('')
sns.despine(top=True, right=True, bottom=True, left=True)
plt.savefig('Top1分类正确率.pdf')

# 一种狗狗被错误分类为另一种狗狗的数量
dogs = list(df['label'].sort_values().unique())
errors = {}
for i in range(len(df)):
	label = df['label'][i]
	pred = df['p1'][i]
	if label != pred:
		key = label + '_' + pred
		errors[key] = errors.get(key, 0) + 1 
errors = sorted(errors.items(), key=lambda x:x[1], reverse=True)
print(errors[:10])

# 热力图
counts = {di:{dj:0 for dj in dogs} for di in dogs}
github YeoLab / gscripts / gscripts / general / dataviz.py View on Github external
x = self.components_.ix[pc].copy()
        x.sort(ascending=True)
        half_features = int(n_features / 2)
        a = x[:half_features]
        b = x[-half_features:]
        if ax is None:
            ax = pylab.gca()
        ax.plot(np.r_[a, b], 'o')
        ax.set_xticks(np.arange(n_features))
        _ = ax.set_xticklabels(np.r_[a.index, b.index], rotation=90)
        ax.set_title("loadings on " + pc)
        x_offset = 0.5
        xmin, xmax = ax.get_xlim()
        ax.set_xlim(left=xmin - x_offset, right=xmax - x_offset)

        seaborn.despine(ax=ax)
github spacetx / starfish / notebooks / py / DARTFISH.py View on Github external
pixel_traces_df = pixel_traces.to_features_dataframe()
pixel_traces_df['area'] = np.pi*pixel_traces_df.radius**2

# pick index of a barcode that was read and decoded from the ImageStack
ind = 4

# get the the corresponding gene this barcode was decoded to
gene = pixel_traces_df.loc[ind].target

# query the codebook for the actual barcode corresponding to this gene
real_barcode = experiment.codebook[experiment.codebook.target==gene].stack(traces=(Axes.ROUND.value, Axes.CH.value)).values[0]
read_out_barcode = pixel_traces[ind,:]

plt.plot(real_barcode, 'ok')
plt.stem(read_out_barcode)
sns.despine(offset=2)
plt.xticks(range(18))
plt.title(gene)
plt.xlabel('Index into R (0:5) and C(0:2)');
# EPY: END code
github stanford-futuredata / optimus-maximus / plots / presentation_plot_utils.py View on Github external
start, end = plt.ylim()
    # if not np.isnan(max_runtime):
    #     plt.ylim([start, max_runtime * 1.1])
    plt.minorticks_on()
    if log:
        ax.set_yscale('log')
        ax.set_ylabel('Time for all users (s, log scale)')
    else:
        ax.set_ylabel('Time for all users (s)')
    plt.xlabel('K')

    plt.grid(True)
    if title:
        plt.title(LABEL_DICT[model] if model in LABEL_DICT else model, y=y_title)
    sns.despine()

    legend = plt.legend(loc='center', bbox_to_anchor=bbox_to_anchor, ncol=ncol)
    save_figure('benchmark-against-blocked-mm-%s' % model, (legend, ))
    plt.show()
github dhhagan / py-openaq / docs / examples / pm25_histogram_delhi.py View on Github external
# Setup a FacetGrid
g = sns.FacetGrid(data=res, col='location', col_wrap=4, size=3, sharex=True,
                    sharey=False)

# Map a histogram for each location
g.map(plt.hist, "value")

# Set the titles
g.set_titles("{col_name}")

# Set the axis labels
g.set_axis_labels("$PM_{2.5}$ [$\mu g m^{-3}$]", None)

# Remove the left axis
sns.despine(left=True)

# Remove the yticks
g.set(yticks=[])
github scvae / scvae / analysis.py View on Github external
figure = pyplot.figure()
    axis = figure.add_subplot(1, 1, 1)
    
    x = linspace(0, D, D)
    
    if bar:
        axis.bar(x, series)
    else:
        axis.plot(x, series)
    
    axis.set_yscale(scale)
    
    axis.set_xlabel(x_label)
    axis.set_ylabel(y_label)
    
    seaborn.despine()
    
    return figure, figure_name
github developmentseed / ml-hv-grid-pub / ml_hv_grid / plot_mapping_speed.py View on Github external
# Set labels
ax2_1.set_ylabel('Km of HV line')
ax2_2.set_ylabel('Number of substations')
ax2_3.set_ylabel('Number of towers')
for ax in [ax2_1, ax2_2, ax2_3]:
    ax.tick_params(axis='x', rotation=60, pad=0)

    for tick in ax.xaxis.get_major_ticks():
        tick.label1.set_horizontalalignment('right')



ax2_1.legend(loc="upper right", bbox_to_anchor=(1.555, 1.05), frameon=True,
             fontsize=13, shadow=True)
plt.tight_layout(w_pad=3)
sns.despine(left=True, top=True)

fig2.savefig(op.join(plot_dir, 'mapped_features.png'), dpi=150)
github autonomio / astetik / astetik / plots / bartwo.py View on Github external
aspect=aspect,
                       size=size,
                       kind='bar',
                       orient='h',
                       ci=error_bars)

    # SCALING AND LIMITS STARTS >>>
    if x_scale != 'linear' or y_scale != 'linear':
        _scaler(p, x_scale, y_scale)

    # FOOTER STARTS >>>
    _titles(title, sub_title=sub_title)
    _footer(p, x_label, y_label, save=save)

    if data[x].min() < 0:
        sns.despine(left=True)
github afrendeiro / toolkit / toolkit / atacseq.py View on Github external
sns.despine(fig)
            fig.savefig(os.path.join(self.results_dir, self.name + ".raw_counts.violinplot.svg"), bbox_inches="tight")

        else:
            attrs = set([getattr(s, by_attribute) for s in samples])
            fig, axis = plt.subplots(len(attrs), 1, figsize=(8, len(attrs) * 6))
            for i, attr in enumerate(attrs):
                print(attr)
                cov = pd.melt(
                    np.log2(1 + self.coverage[[s.name for s in samples if getattr(s, by_attribute) == attr]]),
                    var_name="sample_name", value_name="counts"
                )
                sns.violinplot("sample_name", "counts", data=cov, ax=axis[i])
                axis[i].set_title(attr)
                axis[i].set_xticklabels(axis[i].get_xticklabels(), rotation=90)
            sns.despine(fig)
            fig.savefig(os.path.join(self.results_dir, self.name + ".raw_counts.violinplot.by_{}.svg".format(by_attribute)), bbox_inches="tight")
github calico / basenji / basenji / plots.py View on Github external
corr = None

    if print_sig:
        if csig > .001:
            corr_str += '\n p %.3f' % csig
        else:
            corr_str += '\n p %.1e' % csig

    if corr is not None:
        xlim_eps = (xmax-xmin) * .03
        ylim_eps = (ymax-ymin) * .05

        ax.text(xmin+xlim_eps, ymax-3*ylim_eps, corr_str, horizontalalignment='left', fontsize=12)

    # ax.grid(True, linestyle=':')
    sns.despine()

    # plt.tight_layout(w_pad=0, h_pad=0)

    plt.savefig(out_pdf)
    plt.close()