Skip to content
Prev 298876 / 398506 Next

ggplot: dodge positions

I guess it works with ggplot but not with ggplot2. I'm using only the latter but had a typo in my first post. So the code (which does not do what I want) is:

library(ggplot2)
ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y =
 runif(120,0,10), grp = factor(rep(rep(1:3, 10), 4)))
ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point()

Thinking of it, I would need to find out which offset ggplot uses to dodge the nested factors. If I knew the exact quantity, I could do something like

geom_point(aes(x = offset.used.by.geom_boxplot))

So how are the exact positions on the x-axis for geom_boxplot determined? Any ideas?

Thanks for the help, anyways.

KR,

-Thorn