我过去 3 天一直在使用 R,并且通过研究获得了以下大部分代码,这些代码我已经适应了我的需求。它工作得很好。我希望能够分别用 (B, A*, A, A) 标记/注释标准错误上的误差线。以下是工作代码;
cat<-rep(c("E","F","G","H"),each=12)
var2=rnorm(48,10)*(rep(rpois(4,.2),each=12)/8+1)
ds<-data.frame(cat,var2)
lbls<- c("B","A*","A","A")
stderr <- function(x){sqrt(var(x,na.rm=TRUE)/length(na.omit(x)))}
lowsd <- function(x){return(mean(x)-stderr(x))}
highsd <- function(x){return(mean(x)+stderr(x))}
cols <- c("red", "yellow", "green", "blue")
ggplot(ds,aes(cat,var2, fill=cat))+
ggtitle("Asem beba Dabi")+
xlab("Soil Sample Sites\n\n Fig 1 shows...") + ylab("Mass or Water(mg)") +
# first layer is barplot with means
stat_summary(fun.y=mean, geom="bar", position="dodge", colour="white")+
# second layer overlays
stat_summary(fun.y=mean, fun.ymin=lowsd, fun.ymax=highsd, geom="errorbar", position="dodge",color = 'blue', size=.5)
这是我正在努力的一点
geom_text(aes(label=lbls), position=position_dodge(width=0.9), vjust=-0.25)
这是一项学校作业,我们将不胜感激任何帮助