Add statistically significant difference between bars to plotnine plot (ggpubr equivalent)

Viewed 551

In many plots one wants to highlight the statistical significance of an observed difference between some results. This task can be done in R using the ggpubr() or the geom.signif() extension.

An example of what I mean is here (see horizontal bars with stars): https://www.nature.com/articles/s41598-019-40496-8/figures/1

I am generating the exact same plot as shown in the figure, but my workflow is python-based and it would annoy me to go through R just for this. I would like to obtain something like what is suggested in this other thread for R, but in python plotnine: Put stars on ggplot barplots and boxplots - to indicate the level of significance (p-value)

As far as I could find, there is no way of getting this type of statistical representation with plotnine. Do you have workarounds or suggestions? Am I missing it from the plotnine API?

1 Answers

Came here in search of the same thing, as plotnine's API is missing an equivalent for ggpubr's stat_compare_means (plotnine is an implementation of ggplot2, so perhaps it is not surprising the archives are incomplete).

However, in this thread, I found another library named statannot which seems to do just that.

Related