How to add text to error bar using geom_text

I want to use geom_text to add some character to the error bar in ggplot2. But it is not properly set.
I used the following commands
library(ggplot2)
library(readr)
b1 <- read_csv("C:/Users/ronyg/Downloads/b1.csv")
cha=c('ad','ad','ad' ,'b', 'ac', 'acd', 'ad', 'bc', 'd')
ggplot(b1, aes(x=Pond, y=Mean, fill=Sample)) +
geom_bar(stat="identity", color="black", position=position_dodge()) +
geom_errorbar(aes(ymin=Mean-Sd, ymax=Mean+Sd), width=.2,
position=position_dodge(.9))
p<-ggplot(b1, aes(x=Pond, y=Mean, fill=Sample)) +
geom_bar(stat="identity", color="black", position=position_dodge()) +
geom_errorbar(aes(ymin=Mean-Sd, ymax=Mean+Sd), width=.2,
position=position_dodge(.9))
p+geom_text(aes(label =cha, y=Mean+Sd, hjust =-1)) this code needs to accurately set, I think
The data are

Pond Sample Mean Sd
P1 S2 10.62 1.15
P1 S4 9.42 1.18
P1 S6 9.18 1.19
P2 S2 18.8 1.13
P2 S4 13.43 1.13
P2 S6 11.73 1.13
P3 S2 14.22 1.13
P3 S4 16.48 1.13
P3 S6 7.98 1.18

Can you please help me to fix the problem.

The plot made by my commands is..
image

Thanks in advance

Welcome! I'm afraid you'll need to supply some more info in order for helpers to be able to understand your problem.

The best thing would be if you can make your question into a reproducible example (follow the link for instructions and explanations). To include your data, you'll want to follow one of the methods discussed here.

If you try all that and get stuck, here's a fallback option...
  1. Edit your post and add in some of the code you have tried. It's OK it doesn't work! It's really helpful to see what you've been attempting. Be sure to format your code as code (it's hard to read unformatted code, and it can get garbled by the forum software)
  2. Include sample data:
    • If your data set is OK to share, run the following line and paste the output into your post. Again, be sure to format it as code :sparkles:
    dput(head(your_dataframe_name, 10))
    
    • If your data set can't be shared, run this line instead and paste the output into your post (and yes, format as code!) This will still share some information about your data. If it's truly confidential, I'm afraid you'll need to make a fake sample dataset to share.
    str(your_dataframe_name)
    

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.