Re: [R] ggplot facet spacing, wrapping

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue, 17 Jun 2008 09:06:07 -0500

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)

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 17 Jun 2008 - 14:51:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 17 Jun 2008 - 15:00:48 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive