I have been trying without any success to draw a stacked bar plot with a single error bar on top of each individual bar and not for each sections within bars. I can manage t
You can create a Dummy data set (i did it with data.table
package) that will compute the mean(se)
(although I don't think it's the best practice) and plot it as following (I've changed the color of the error bars so you could see them better)
dodge<- position_dodge(width = 0.65)
cols <- c(Top="darkgrey",Bottom="lightgrey", Well_plate="white")
library(data.table)
Dummy <- data.table(df)[, list(Rate = sum(Rate), se = mean(se), Or = "WP"), by = c("Sp", "Type")]
ggplot(df,aes(x=factor(Type),y=Rate,fill=factor(Or))) +
geom_bar(aes(width=.65), stat="identity",colour="black")+
geom_errorbar(data = Dummy, aes(ymax = Rate +se, ymin= Rate -se), position="dodge", colour="red", width=.65)+
scale_fill_manual(values = cols)+
facet_grid(. ~ Sp)