I have this data.frame
my.df = data.frame(mean = c(0.045729661,0.030416531,0.043202944,0.025600973,0.040526913,0.046167044,0.029352414,0.021477789,0.02758052
Here's what worked for me:
p1 = ggplot(data = my.df, aes(factor(replicate), color = factor(parent.origin)))
p1 = p1 + geom_boxplot(aes(fill = factor(parent.origin),lower = mean - std.dev,
upper = mean + std.dev, middle = mean, ymin = mean - 3*std.dev,
ymax = mean + 3*std.dev), position = position_dodge(width = 0), width = 0.5,
alpha = 0.5, stat="identity") +
facet_wrap(~group, ncol = 4)+
scale_fill_manual(values = c("red","blue"),labels = c("maternal","paternal"),
name = "parental allele")+
scale_colour_manual(values = c("red","blue"),labels = c("maternal","paternal"),
name = "parental allele")
The width value within the position_dodge
parameter determines the separation between the red and blue boxes per each replicate, and the other width parameter controls the width o he box. The alpha value controls transparency.