I have a boxplot that I've created using ggboxplot. On it I have a horizontal line at the mark y=50. I want to be able to add a label at y=50, x=0 saying "50" in dark green to match the line. Currently the label overlaps the axis line and the boxplots have shifted to the right. Any suggestions?
Problem
Current Code
symnum.args <- list(cutpoints = c(0, 0.0001, 0.001, 0.01, 0.05, 1), symbols = c("", "", "", "", "ns"))
my_comparisons<- list(c('BVR3', 'BVR4'), c('BVR6', 'BVR1'), c('BVR6', 'BVR2'), c('BVR6', 'BVR4'), c('BVR6', 'BVR5'))
plot <- ggboxplot(TPdat, x = "loc", y = "TP",
ylab = "Median Annual Total Phosphorus (\U00B5g/L)", xlab = "Sampling Site",
outlier.shape=NA, ylim=c(0, 925)) +
scale_x_discrete(labels=c('1','2','3','4','5','6')) +
theme(axis.text=element_text(size=16, family='Calibri'),
axis.title=element_text(size=16, family='Calibri')) +
geom_hline(yintercept=50, col='dark green', linetype=2) +
coord_cartesian(clip='off', ylim=c(0, NA)) +
annotate("text", x=0, y=50, label="50", colour='dark green', size=5) +
stat_compare_means(comparisons=my_comparisons, label='p.signif',
symnum.args = symnum.args,
tip.length = c(0.01,0.01,0.01,0.01,0.01),
label.y=c(800, 825, 850, 875, 900)) +
stat_compare_means(label.y=930, family='Calibri', size=5)
head of dataframe
structure(list(loc = structure(c(1L, 1L, 1L, 1L, 1L, 1L), levels = c("BVR1",
"BVR2", "BVR3", "BVR4", "BVR5", "BVR6"), class = "factor"), TP = c(76L,
71L, 86L, 48L, 58L, 73L)), row.names = c(NA, 6L), class = "data.frame")