[R] ggplot facet spacing, wrapping
h.wickham at gmail.com
Tue Jun 17 16:06:07 CEST 2008
On Tue, Jun 17, 2008 at 5:54 AM, mfrumin <michael at frumin.net> wrote:
> I'm running into some problems with the spacing of some faceted ggplot plots.
> I have a number of time series faceted to be one above another, but the
> scale labels of the y axes all clobber each other at the bottom/top of each.
> for example, try:
> qplot(x, y, data = data.frame(x = 1:10, y = 1:10, size = 1:10), facets =
> size ~ ., size = size) + scale_x_continuous(breaks = 1:10) +
> scale_y_continuous(limits = c(0,10))
> and notice the 10's and the 0's on the respective Y axes are mushing each
> other. Is there a way to adjust the spacing of facets in a faceted plot?
Not at the moment, but it's on my to do list to be completed this summer.
> Likewise, what about wrapping, so that if I had say 20 or 30 facets it would
> make a grid of facets rather than 30 in a column (or in a row).
Again, on the to do list. You can kind of do it yourself though, if
you really really want it. The basic idea is as follows:
df <- data.frame(x = 1:10, y = 1:10, size = 1:10)
df <- transform(df,
xgrid = x %% 4,
ygrid = y %/% 4
qplot(x, y, data=df, facets = xgrid ~ ygrid)
More information about the R-help