如何在使用ggplot2创建的barplot上添加条纹

时间:2019-02-20 13:05:31

标签: r ggplot2

我使用ggplot2创建了以下barplot。但是,我想添加星星以显示相同处理在暗和亮之间的重要性。例如SW.5处理。

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)

我该怎么做?

0 个答案:

没有答案