Skip to content

Instantly share code, notes, and snippets.

View trevismd's full-sized avatar

Florian Charlier trevismd

  • Belgium
View GitHub Profile
# Putting the parameters in a dictionary avoids code duplication
# since we use the same for `sns.boxplot` and `Annotator` calls
plotting_parameters = {
'data': rfs,
'x': 'Subcategory',
'y': 'Goal',
'palette': subcat_palette[1:]
}
pairs = [('Robots', 'Flight'),
@trevismd
trevismd / Statannotations-Tutorial-1-19.py
Last active July 21, 2021 15:01
Annotating with star notation
with sns.plotting_context("notebook", font_scale = 1.4):
# ...Same as previous
# Add annotations
annotator = Annotator(ax, pairs, **plotting_parameters)
annotator.set_pvalues(pvalues)
annotator.annotate()
# ... same as previous
@trevismd
trevismd / Statannotations-Tutorial-1-20.py
Last active July 21, 2021 15:03
Using simple format
# Add annotations
annotator = Annotator(ax, pairs, **plotting_parameters)
annotator.configure(text_format="simple")
annotator.set_pvalues_and_annotate(pvalues)
# Add annotations
annotator.new_plot(ax, **plotting_parameters)
annotator.configure(test_short_name="MWW") # text_format is still simple
annotator.set_pvalues_and_annotate(pvalues)
@trevismd
trevismd / Statannotations-Tutorial-1-22.py
Last active July 7, 2021 20:50
Tweaking text_offset
# Also disabling printed output as it is the same
annotator.configure(text_offset=3, verbose=0)
states_palette = states_palette = sns.color_palette("YlGnBu", n_colors=5)
states_order = ["Successful", "Failed", "Live", "Suspended", "Canceled"]
@trevismd
trevismd / Statannotations-Tutorial-1-23.py
Last active July 21, 2021 15:01
Performing statistical test
with sns.plotting_context('notebook', font_scale = 1.4):
# ... same as before
# Add annotations
annotator.new_plot(ax, pairs=pairs, **plotting_parameters)
annotator.configure(test='Mann-Whitney', verbose=True).apply_and_annotate()
# ... same as before
# Add annotations
annotator.new_plot(ax, **plotting_parameters)
annotator.configure(text_format="full", verbose=False).apply_and_annotate()
pairs = [
("Successful", "Failed"),
("Successful", "Live"),
("Failed", "Live"),
("Canceled", "Successful"),
("Canceled", "Failed"),
("Canceled", "Live")
]
state_plot_params = {
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",