I would like to add significance brackets to ggplot geom_bar object in r.
When I do searches for how to do this, it either shows just adding the astericks without the brackets, or it does so using a geom_boxplot.
I would like to add significance brackets to ggplot geom_bar object in r.
When I do searches for how to do this, it either shows just adding the astericks without the brackets, or it does so using a geom_boxplot.
Here's a reproducible example using ggsignif, with the built-in iris data set:
library(ggplot2)
library(ggsignif)
ggplot(iris, aes(Species, Sepal.Length)) +
stat_summary(fun = "mean", fill = "#0079b9", geom = "col", width = 0.7) +
geom_signif(comparisons = list(c("setosa", "versicolor"),
c("versicolor", "virginica"),
c("virginica", "setosa")),
y_position = c(7, 7.5, 8)) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 8.9)) +
ylab("Mean Sepal Length") +
theme_classic(base_size = 16) +
theme(panel.border = element_rect(fill = NA))
Created on 2022-06-30 by the reprex package (v2.0.1)