In the following example, how do I set separate ylims for each of my facets?
qplot(x, value, data=df, geom=c(\"smooth\")) + facet_grid(variable ~ ., scale=\
There are actually two packages that solve that problem now:
https://github.com/zeehio/facetscales, and https://github.com/teunbrand/ggh4x.
I would recommend using ggh4x
because it has very useful tools, such as facet grid multiple layers (having 2 variables defining the rows or columns), scaling the x and y-axis as you wish in each facet, and also having multiple fill and colour scales.
For your problems the solution would be like this:
library(ggh4x)
scales <- list(
# Here you have to specify all the scales, one for each facet row in your case
scale_y_continuous(limits = c(2,10),
scale_y_continuous(breaks = c(3, 4))
)
qplot(x, value, data=df, geom=c("smooth")) +
facet_grid(variable ~ ., scale="free_y") +
facetted_pos_scales(y = scales)