I would like to create a stacked barplot with unidirectional error bars (to avoid overlapping) in r. However, when I use the barplot2
function of gplots and omit besides=T
, the automatic display of error bars is inhibited.
Here is a dummy dataset to represent my data:
BM=data.frame(Treatment=gl(3,4,24,labels=c("T1","T2","T3")),
Loc=gl(2,12,24,labels=letters[1:2]),Ind=gl(4,1,24,labels=c(1,2,3,4)),
Weight=runif(24))
I used the following codes:
mean.BM=tapply(Weight,list(Loc,Treatment),mean)
sd.BM=tapply(Weight,list(Loc,Treatment),sd)
bplot1=barplot2(mean.BM,panel.first=T,plot.ci=T,
ci.u=mean.BM+(0.5*sd.BM), col=c("grey30","grey80"))
Unfortunately I cannot post any images yet, I hope the question is clear anyway!
I am aware that there are probably more elegant ways to do this with ggplot2, but since I am not familiar with this package I would prefer a solution with gplots. If this is not possible, I am grateful for any other suggestion of course!