trevismd / statannotations

add statistical significance annotations on seaborn plots. Further development of statannot, with bugfixes, new features, and a different API.
Other
619 stars 67 forks source link

how to use statannotations in FaceGrid of seaborn #120

Open ryrl9703 opened 1 year ago

ryrl9703 commented 1 year ago

I just want to draw a figure by FacetGrid in seaborn and add test in it just like the example in the homepage, how should I do? Xnip2023-05-05_10-16-31

trevismd commented 1 year ago

Hi! You should use the plot_and_annotate_facets function, see some documentation here: https://statannotations.readthedocs.io/en/latest/statannotations.html#statannotations.Annotator.Annotator.plot_and_annotate_facets, to read if/when you are familiar with the basic flows of the package explained in the example notebook or the blog post.

JohannesWiesner commented 10 months ago

I also would like to do this but I cannot find any tutorial on this. Seems like this figure (example_2facets.png) only appears in the README but nowhere in the tutorials

trevismd commented 9 months ago

Here should be the code to this image (with the dataset used in the tutorial, overdue part 2 will cover FacetGrids).

annot = Annotator(None, pairs)

g = sns.FacetGrid(sf, col='State', height=12, sharey=False)
g.map_dataframe(annot.plot_and_annotate_facets, plot='boxplot',
                plot_params=plotting_parameters,
                configuration={"test": "Mann-Whitney"}, annotation_func="apply_test",
                ax_op_before=[["set_yscale", ["log"], {}]])
g.set_axis_labels("Technology Subcategory", "Goal")
g.fig.patch.set_alpha(1)
plt.show()