# 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.

mogoweb / aiexamples / AIDog / tflite / scripts / stats.py View on Github
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}
YeoLab / gscripts / gscripts / general / dataviz.py View on Github
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)
x_offset = 0.5
xmin, xmax = ax.get_xlim()
ax.set_xlim(left=xmin - x_offset, right=xmax - x_offset)

seaborn.despine(ax=ax)
spacetx / starfish / notebooks / py / DARTFISH.py View on Github
pixel_traces_df = pixel_traces.to_features_dataframe()

# 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]

plt.plot(real_barcode, 'ok')
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
stanford-futuredata / optimus-maximus / plots / presentation_plot_utils.py View on Github
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()
dhhagan / py-openaq / docs / examples / pm25_histogram_delhi.py View on Github
# 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=[])
scvae / scvae / analysis.py View on Github
figure = pyplot.figure()

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
developmentseed / ml-hv-grid-pub / ml_hv_grid / plot_mapping_speed.py View on Github
# 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]:

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,
sns.despine(left=True, top=True)

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

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

# FOOTER STARTS &gt;&gt;&gt;
_titles(title, sub_title=sub_title)
_footer(p, x_label, y_label, save=save)

if data[x].min() &lt; 0:
sns.despine(left=True)
afrendeiro / toolkit / toolkit / atacseq.py View on Github
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")
calico / basenji / basenji / plots.py View on Github
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.savefig(out_pdf)
plt.close()

## seaborn

Statistical data visualization

BSD-3-Clause