I have a plot of four locations and in each locations there are sets of three boxplots for three years.
I have a table of pairwise comparisons to show significance.
I'm interested in adding in significance labels to indicate pairs that are not significantly different.
Current Code
# library(ggh4x)
color <- c("light blue", "#B4EDD2","#E86A92","#F6AE2D")
scaledDaily$year <- as.factor(scaledDaily$year)
scaleBox <- scaledDaily %>%
ggplot(aes(x=label2, y=mAODscale, fill=year)) +
geom_hline(yintercept=0, color='grey') +
geom_boxplot() +
labs(y="Scaled Water Depth (mAOD)", x="Location", fill="Year (Mar-Feb)") +
guides(fill=guide_legend(ncol=1)) +
facet_wrap2(~mere, ncol=1, trim_blank = TRUE, scales='free_x',
strip=strip_nested(bleed=FALSE, background_x=elem_list_rect(fill=color))) +
theme_bw() +
theme(text=element_text(size=14, 'Calibri'))
plot(scaleBox)
Test Data
This is not my actual data, I've made it up.
structure(list(lable2 = c("B1", "B1", "B1", "B1", "B1", "B1", "B1",
"B1", "B1", "B2", "B2", "B2", "B2", "B2", "B2", "B2", "B2", "B2",
"B3", "B3", "B3", "B3", "B3", "B3", "B3", "B3", "B3", "CH1",
"CH1", "CH1", "CH1", "CH1", "CH1", "CH1", "CH1", "CH1", "CH2",
"CH2", "CH2", "CH2", "CH2", "CH2", "CH2", "CH2", "CH2", "CH3",
"CH3", "CH3", "CH3", "CH3", "CH3", "CH3", "CH3", "CH3"), mAODscale = c(0.561948848,
0.851883432, 0.293151829, 0.683807808, 0.864472706, 0.380303934,
0.324501709, 0.765022304, 0.900772901, 0.204731715, 0.877104175,
0.56367162, 0.206528162, 0.353350116, 0.219628257, 0.840723901,
0.716389918, 0.569798858, 0.707583441, 0.120064246, 0.275325307,
0.438391155, 0.308969668, 0.350156436, 0.886955315, 0.693416677,
0.710065022, 0.561948848, 0.851883432, 0.293151829, 0.683807808,
0.864472706, 0.380303934, 0.324501709, 0.765022304, 0.900772901,
0.204731715, 0.877104175, 0.56367162, 0.206528162, 0.353350116,
0.219628257, 0.840723901, 0.716389918, 0.569798858, 0.707583441,
0.120064246, 0.275325307, 0.438391155, 0.308969668, 0.350156436,
0.886955315, 0.693416677, 0.710065022), year = c(1L, 1L, 1L,
2L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 1L,
1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L,
3L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 2L,
3L, 3L, 3L), mere = c("hatch", "hatch", "hatch", "hatch", "hatch",
"hatch", "hatch", "hatch", "hatch", "hatch", "hatch", "hatch",
"hatch", "hatch", "hatch", "hatch", "hatch", "hatch", "hatch",
"hatch", "hatch", "hatch", "hatch", "hatch", "hatch", "hatch",
"hatch", "chapel", "chapel", "chapel", "chapel", "chapel", "chapel",
"chapel", "chapel", "chapel", "chapel", "chapel", "chapel", "chapel",
"chapel", "chapel", "chapel", "chapel", "chapel", "chapel", "chapel",
"chapel", "chapel", "chapel", "chapel", "chapel", "chapel", "chapel"
)), class = "data.frame", row.names = c(NA, -54L))
Test Data Plot
In this test data plot. How would I for example put significance bars between Year 2 and 2 in the CH3 site. and the Year 1, 2, and 3 for B1. The significance tests I've run are Kruskal-Wallis and pairwise comparisons.
