-1

I am trying to add significancy bar to may grouped barplot using geom_signif in R. The problem is that, since I have applied scale_x_discrete on x axis, I can't define numeric values like xmin and xmax for the begining and ending point of the significancy bar.

x=ggplot(data, aes(fill=condition ,x=names ,y=M$Mean, ymin=M$Mean-M$SE, ymax=M$Mean+M$SE))+ 
  geom_bar(position="dodge", stat="identity", width=2.5)+
  geom_errorbar(position=position_dodge(2.5) , aes(ymin =Mean))+
  geom_signif(annotations = "***", xmin=1, xmax=2, y_position=7.05, tip_length=0.03)+
  scale_x_discrete(limits=names )+
  scale_fill_discrete(labels = c("D0", "D3", "D6" , "D12"))

I also did not succeed plot my desired significancy bars by using comparisons instead of xmax and xmin. The reason is that it is a grouped barplot and several conditions have the same x label.

my barplot

Can anybody suggest a solution?

tblznbits
  • 6,602
  • 6
  • 36
  • 66
Elham
  • 1
  • 3
  • We need to see some data, as well as your code, and what you have tried before we can help. Otherwise, we don't know where to start. – tblznbits Oct 26 '18 at 15:01
  • @brittenb Thanks. I added my barplot image as well as the code. – Elham Oct 26 '18 at 15:29

1 Answers1

0

Your use of aes( y=M$Mean...etc) is incorrect - the aes call cannot handle the reference. see link. If you need to use these variables, add them to your dataframe.

bob1
  • 398
  • 3
  • 12
  • Thanks for your comment. Actually M$Mean is name of one the columns of my dataframe (data) and that section of the code is working properly. – Elham Oct 27 '18 at 15:38