This question has been asked a few times, but I've read them all and cannot find an answer.
df <- data.frame(f1=factor(rbinom(100, 1, 0.45), label=c("m","w")),
f2=factor(rbinom(100, 1, 0.45), label=c("young","old")),
boxthis=rnorm(100))
ggplot(aes(y=boxthis, x=f2), data=df)
+ geom_boxplot()
+ facet_grid(~f1, scales="free")
This generates the plot below, but the y axis is shared across the facet column. In my real data, this is a problem as each factor in f1
needs a widely different axis range. Is there some trick to getting free
to work here?
I have found that free
works as expected when making the facet vertical, as shown below, but this clearly looks horrid compared to making the facet horizontal
ggplot(aes(y=boxthis, x=f2), data=df)
+ geom_boxplot()
+ facet_grid(f1~., scales="free")