1

I used ggplot2 to create the following barplot. However, I would like to add stars to show the significancy between the dark and light for the same treatment. For instance SW.5 treatment.

enter image description here

calen_per<- read.table("sadek calen percent.csv", sep=";",header = TRUE)
calen_per
DW SW.1 SW.2 SW.3 SW.4 SW.5           LVD
70   85   80   70   75   84 Light (79.5a)
75   90   85   77   72   86 Light (79.5a)
78   85   80   75   75   90 Light (79.5a)
72   70   74   65   70   70  Dark (70.8b)
75   72   70   70   72   75  Dark (70.8b)
70   75   70   70   65   70  Dark (70.8b)
cal_per <- melt(calen_per,id="LVD")
g8<-ggplot(cal_per, aes(x=variable, y=value, fill=as.factor(LVD))) 
+ stat_summary(fun.y=mean,geom="bar",position=position_dodge(),
colour="black",width=.7,size=.5)+ 
stat_summary(fun.ymin=min,fun.ymax=max,geom="errorbar",
color="black",position=position_dodge(.7), width=.2) +
stat_summary(geom = 'text', fun.y = max, position = position_dodge(.7), 
label = c("B","a","A","a","AB","a", "B","a","B","a","A","a"), vjust = -0.5)+
scale_fill_manual("marigold", 
values = c("Light (79.5a)" = "white", "Dark (70.8b)" = "grey")) +
xlab("treatments")+ylab("percentage") +
theme(panel.background = element_rect(fill = 'white', colour = 'black'))+ 
ylim(0,120)

How can I do this?

user3801226
  • 65
  • 1
  • 6
  • Please, [edit] your question and provide a [mcve] including a sample dataset - Thank you. – Uwe Feb 20 '19 at 13:09
  • I added a complete dataset as you recommended and I hope it is clear now. Thanks for your time and help – user3801226 Feb 20 '19 at 13:41
  • 1
    Possible duplicate of [Put stars on ggplot barplots and boxplots - to indicate the level of significance (p-value)](https://stackoverflow.com/questions/17084566/put-stars-on-ggplot-barplots-and-boxplots-to-indicate-the-level-of-significanc) – erc Feb 20 '19 at 13:49
  • title says streak, description says stars. This is misleading search results – Scientist Apr 20 '22 at 10:15

0 Answers0