Would like to display sample size next to bars on a geom_errorbars plot

Does anyone know how this can be done?

Heres my code:

FuncGrpPlot <- ggplot(SummFuncGrpMAIZEna, aes(FuncGrp, yi))+
geom_col(fill="lightgrey", colour="black") +
geom_errorbar(aes(ymin = yi - ci, ymax = yi + ci), width=0.3) +
ggtitle("Effect of Bt Maize on Abundance of Arthropods, by Function Group") +
labs(y="Effect Size", x = "Function Group") + theme_bw()
FuncGrpPlot

Can't paste chart in unfortunately but it's a bar chart with error bars on. Just want sample sizes to appear next to the top or bottom of each bar. Sample sizes are contained in my 'SummFuncGrpMAIZEna' summary table.

Many thanks!!
Annabel

check out geom_text something like this might work.

ggplot(SummFuncGrpMAIZEna, aes(FuncGrp, yi))+
  geom_col(fill="lightgrey", colour="black") +
  geom_errorbar(aes(ymin = yi - ci, ymax = yi + ci), width=0.3) +
  ggtitle("Effect of Bt Maize on Abundance of Arthropods, by Function Group") +
  labs(y="Effect Size", x = "Function Group") + theme_bw() +
  geom_text(aes(label = [name of sample size variable]))
4 Likes

Genius!!! Thank you!!