I am in a new field where they put letters directly on top of error bars to denote significance. I am able to put labels on top of my error bars, but they are uniformly spaced away from the bars, leaving some with small errors very far away from the bars and looking very strange. Is there a way to put the letter right on top of the error bar? In other words, can I adjust each individual label for each bar?
Here is my code:
my_lab<-c("A","B","BC","C","C","BC")
ggplot(g, aes(x=factor(rate, level=c('0','0.1','1.8','7.3','10.3','15.3')), y=number, fill=species)) +
geom_bar(stat='identity', color="black", width = 0.5)+
geom_errorbar(aes(ymax=number+se, ymin=number), width=0.2)+
labs(y=my_y_title, x=expression("Ethanol release rate (g/day)"))+
geom_text(data=g, aes(label=my_lab), size=8, vjust=-23)+
theme(panel.grid.major = ele[enter image description here][1]ment_blank(),
panel.grid.minor = element_blank(),panel.background = element_blank(),
axis.line = element_line(colour = "black"))+
theme(text = element_text(size=20))+
theme(axis.text.x = element_text(vjust = 0.95, hjust=1))+
theme(axis.text.y = element_text(hjust=1))+
theme(legend.position = "none")+
scale_fill_manual(values=c('#104E8BC8'))+
theme(plot.title = element_text(vjust = -12, hjust = 0.7))+
theme(plot.subtitle = element_text(vjust = -12, hjust = 0.7))+
theme(plot.margin = margin(t = 0, # Top margin
r = 0, # Right margin
b = 0, # Bottom margin
l = 0))```