Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def draw_group_boxplot(name_list,data_list1,data_list2, label ='Dice Score',titile=None, fpth=None ):
df = get_df_from_list(name_list,data_list1,data_list2)
df = df[['Group', 'Longitudinal', 'Cross-subject']]
dd = pd.melt(df, id_vars=['Group'], value_vars=['Longitudinal', 'Cross-subject'], var_name='task')
fig, ax = plt.subplots(figsize=(15, 8))
sn=sns.boxplot(x='Group', y='value', data=dd, hue='task', palette='Set2',ax=ax)
#sns.palplot(sns.color_palette("Set2"))
sn.set_xlabel('')
sn.set_ylabel(label)
# plt.xticks(rotation=45)
ax.yaxis.grid(True)
leg=plt.legend(prop={'size': 18},loc=4)
leg.get_frame().set_alpha(0.2)
for item in ([ax.title, ax.xaxis.label, ax.yaxis.label] +
ax.get_xticklabels() + ax.get_yticklabels()):
item.set_fontsize(20)
for tick in ax.get_xticklabels():
tick.set_rotation(30)
if fpth is not None:
plt.savefig(fpth,dpi=500, bbox_inches = 'tight')
plt.close('all')
else:
def barcode_length_boxplot(result_dict, datafame_dict, main, my_dpi, result_directory, desc):
"""
Plot boxplot of the 1D pass and fail read length for each barcode indicated in the sample sheet
"""
output_file = result_directory + '/' + '_'.join(main.split()) + '.png'
plt.figure(figsize=(figure_image_width / my_dpi, figure_image_height / my_dpi), dpi=my_dpi)
plt.subplot()
ax = sns.boxplot(data=datafame_dict['barcode_selection_sequence_length_melted_dataframe'],
x='barcodes', y='length', hue='passes_filtering',
showfliers=False, palette={True: "yellowgreen", False: "orangered"},
hue_order=[True, False])
handles, _ = ax.get_legend_handles_labels()
plt.legend(bbox_to_anchor=(0.905, 0.98), loc=2, borderaxespad=0., labels=["Pass", "Fail"], handles=handles)
plt.xlabel('Barcodes')
plt.ylabel('Read length(bp)')
df = datafame_dict['barcode_selection_sequence_length_dataframe']
all_read = df.describe().T
read_pass = df.loc[df['passes_filtering'] == bool(True)].describe().T
read_fail = df.loc[df['passes_filtering'] == bool(False)].describe().T
concat = pd.concat([all_read, read_pass, read_fail], keys=['1D', '1D pass', '1D fail'])
dataframe = concat.T
"""
Grouped boxplots
================
_thumb: .66, .45
"""
import seaborn as sns
sns.set(style="ticks", palette="pastel")
# Load the example tips dataset
tips = sns.load_dataset("tips")
# Draw a nested boxplot to show bills by day and time
sns.boxplot(x="day", y="total_bill",
hue="smoker", palette=["m", "g"],
data=tips)
sns.despine(offset=10, trim=True)
def paper_plot(corrs, filename):
fig, ax = plt.subplots(figsize=(3.3, 3.0))
colors = sb.color_palette("PRGn")
order = ['APS', 'TPS', 'SAR', 'ISR', 'SIR', 'IPS']
sb.boxplot(y='metric', x='corr',
order=order,
dodge=False,
data=corrs,
whis=0,
fliersize=0,
ax=ax,
)
# iterate over boxes
for i, box in enumerate(ax.artists):
box.set_edgecolor('black')
box.set_facecolor('white')
# Add some small jitter
np.random.seed(1111)
corrs['corr'] += np.random.uniform(-0.01, 0.01, size=len(corrs))
meds['normalised_rating2'] = meds2['normalised_rating']
func = ln.utils.concordance
concordance = meds.groupby(['experiment', 'page']).apply(
lambda g: func(g['normalised_rating'].values,
g['normalised_rating2'].values
)
).reset_index()
concordance.boxplot(column=0, by=['experiment'])
plt.show()
error = (meds['normalised_rating'] - meds['normalised_rating2']).abs()
print(error.quantile(0.95))
sb.boxplot(error)
plt.show()
g.map(qqplot, "total_bill", "tip", s=40, edgecolor="w")
g.add_legend();
#
def hexbin(x, y, color, **kwargs):
cmap = sns.light_palette(color, as_cmap=True)
plt.hexbin(x, y, gridsize=10, cmap=cmap, **kwargs)
with sns.axes_style("dark"):
g = sns.FacetGrid(mtcars, hue="gear", row='gear', col="cyl", height=4)
g.map(hexbin, "wt", "mpg");
#%%
cmap = sns.color_palette("Set3")
sns.boxplot(x='cyl', y='mpg', data=mtcars, palette=cmap);
plt.xticks(rotation=45);
#make maximum possible 500
df.loc[df['score']>500,'score'] = 500
#match plot
df_match = df[(df['mismatch_score'] == -2) & (df['gap_score'] == -1)]
g = sns.FacetGrid(df_match, col="match_score")
g = g.map(sns.boxplot, "match", "score")
sns.plt.ylim(0,400)
sns.plt.show()
#mismatch plot
df_mismatch = df[(df['match_score'] == 3) & (df['gap_score'] == -1)]
g = sns.FacetGrid(df_mismatch, col="mismatch_score")
g = g.map(sns.boxplot, "match", "score")
sns.plt.ylim(0,400)
sns.plt.show()
#gap plot
df_gap = df[(df['match_score'] == 3) & (df['mismatch_score'] == -2)]
g = sns.FacetGrid(df_gap, col="gap_score")
g = g.map(sns.boxplot, "match", "score")
sns.plt.ylim(0,400)
sns.plt.show()
# functional ANOVA sometimes crashes with a RuntimeError, e.g., on tasks where the performance is constant
# for all configurations (there is no variance). We will skip these tasks (like the authors did in the
# paper).
print('Task %d error: %s' % (task_id, e))
continue
# transform ``fanova_results`` from a list of dicts into a DataFrame
fanova_results = pd.DataFrame(fanova_results)
##############################################################################
# make the boxplot of the variance contribution. Obviously, we can also use
# this data to make the Nemenyi plot, but this relies on the rather complex
# ``Orange`` dependency (``pip install Orange3``). For the complete example,
# the reader is referred to the more elaborate script (referred to earlier)
fig, ax = plt.subplots()
sns.boxplot(x='hyperparameter', y='fanova', data=fanova_results, ax=ax)
ax.set_xticklabels(ax.get_xticklabels(), rotation=45, ha='right')
ax.set_ylabel('Variance Contribution')
ax.set_xlabel(None)
plt.tight_layout()
plt.show()
def _plot_category(self, name):
data = self._train_features_df.dropna(subset=[name])
self._plot(sns.countplot(x=name, data=data))
self._plot(sns.boxplot(x=name, y=self._target_col,
data=data))
b.set_xlabel('')
b.set_ylabel('')
b.legend(fontsize=30)
b.tick_params(labelsize=30)
plt.savefig(dice_file)
plt.figure()
b = sns.boxplot(x='struc', y='hd', hue='phase', data=df, palette="PRGn")
b.set_xlabel('')
b.set_ylabel('')
b.legend(fontsize=30)
b.tick_params(labelsize=30)
plt.savefig(hd_file)
plt.figure()
b = sns.boxplot(x='struc', y='assd', hue='phase', data=df, palette="PRGn")
b.set_xlabel('')
b.set_ylabel('')
b.legend(fontsize=30)
b.tick_params(labelsize=30)
plt.savefig(assd_file)
print('--------------------------------------------')
print('the following measures should be the same as online')
for struc_name in ['LV', 'RV', 'Myo']:
for cardiac_phase in ['ED', 'ES']:
dat = df.loc[(df['phase'] == cardiac_phase) & (df['struc'] == struc_name)]
print('{} {}, mean += std Dice: {:.3f} ({:.3f})'.format(cardiac_phase, struc_name, np.mean(dat['dice']), np.std(dat['dice'])))
print('{} {}, mean Hausdorff: {:.2f} ({:.2f})'.format(cardiac_phase, struc_name, np.mean(dat['hd']), np.std(dat['hd'])))