Skip to content

Instantly share code, notes, and snippets.

View trevismd's full-sized avatar

Florian Charlier trevismd

  • Belgium
View GitHub Profile
for result, corrected_result in zip(results, corrected_results):
print(f"{result.pvalue:.2e} => {corrected_result.pvalue:.2e}")
@trevismd
trevismd / Statannotations-Tutorial-1-32.py
Last active July 25, 2021 13:51
A horizontal barplot
hue_plot_params = {**hue_plot_params,
'x': 'Goal','y': 'State',
'dodge': True, 'orient': 'h'}
with sns.plotting_context("notebook", font_scale=1.4):
# Create new plot
ax = get_log_ax('h')
# Plot with seaborn
ax = sns.barplot(ax=ax, **hue_plot_params)
@trevismd
trevismd / Statannotations-Tutorial-1-31.py
Last active July 21, 2021 15:50
Applying Bonferroni
with sns.plotting_context("notebook", font_scale = 1.4):
# Create new plot
ax = get_log_ax()
# Plot with seaborn
ax = sns.boxplot(ax=ax, **hue_plot_params)
# Add annotations
annotator = Annotator(ax, pairs, **hue_plot_params)
annotator.configure(test="Mann-Whitney", comparisons_correction="bonferroni")
pairs =(
[('Successful', 'Robots'), ('Successful', 'Flight')],
[('Successful', 'Flight'), ('Successful', 'Sound')],
[('Successful', 'Robots'), ('Successful', 'Sound')],
[('Failed', 'Robots'), ('Failed', 'Flight')],
[('Failed', 'Flight'), ('Failed', 'Sound')],
[('Failed', 'Robots'), ('Failed', 'Sound')],
[('Live', 'Robots'), ('Live', 'Flight')],
# Switching hue and x
hue_plot_params = {
'data': rfs,
'x': 'State',
'y': 'Goal',
"order": states_order,
"hue": "Subcategory",
"hue_order": subcat_order,
"palette": subcat_palette
}
hue_plot_params = {
'data': rfs,
'x': 'Subcategory',
'y': 'Goal',
"order": subcat_order,
"hue": "State",
"hue_order": states_order,
"palette": state_palette
}
pairs = [
[('Robots', 'Successful'), ('Robots', 'Failed')],
[('Flight', 'Successful'), ('Flight', 'Failed')],
[('Sound', 'Successful'), ('Sound', 'Failed')],
[('Robots', 'Successful'), ('Robots', 'Live')],
[('Flight', 'Successful'), ('Flight', 'Live')],
[('Sound', 'Successful'), ('Sound', 'Live')],
[('Robots', 'Failed'), ('Robots', 'Live')],
with sns.plotting_context('notebook', font_scale = 1.4):
# Create new plot
ax = get_log_ax()
# Plot with seaborn
ax = sns.boxplot(ax=ax,
data=rfs,
x='Subcategory', y='Goal',
order=subcat_order,
hue="State",
pairs = [
("Successful", "Failed"),
("Successful", "Live"),
("Failed", "Live"),
("Canceled", "Successful"),
("Canceled", "Failed"),
("Canceled", "Live")
]
state_plot_params = {
# Add annotations
annotator.new_plot(ax, **plotting_parameters)
annotator.configure(text_format="full", verbose=False).apply_and_annotate()