Skip to content

Instantly share code, notes, and snippets.

@trevismd
Last active July 22, 2021 20:46
Show Gist options
  • Save trevismd/8f63163fa57ff4798459bf03fc227074 to your computer and use it in GitHub Desktop.
Save trevismd/8f63163fa57ff4798459bf03fc227074 to your computer and use it in GitHub Desktop.
Annotating Plot 1
# 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'),
('Flight', 'Sound'),
('Robots', 'Sound')]
with sns.plotting_context('notebook', font_scale = 1.4):
# Create new plot
ax = get_log_ax()
# Plot with seaborn
sns.boxplot(**plotting_parameters)
# Add annotations
annotator = Annotator(ax, pairs, **plotting_parameters)
annotator.set_custom_annotations(formatted_pvalues)
annotator.annotate()
# Label and show
label_plot_for_subcats(ax)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment