On Tue, Mar 24, 2009 at 11:45 AM, Elaine <elaine...@gmail.com> wrote:
>
> I have been searching for a way to split my plots into multiple
> pages. I often have too many facets to easy view on one page, and I'd
> like to be able to specify how many should go on each page, causing
> the rest to spill onto the next page. Is there a way to do this in
> ggplot? Right now I'm subsetting the data in order to do this, but
> this is not desireable for several obvious reasons . . .
I currently don't have any plans to support multiple pages, but they
are quite easy to do yourself. Here's some example code I sent to
someone else who was interested in multiple pages of output:
# Assuming your data frame is called df and your patient identifier is
patient_id
df$group <- as.numeric(factor(df$patient_id)) %/% 49
# The plot you want to split into multiple pages
plot <- qplot(time, response, data = df, geom = "line", colour = treatment) +
facet_grid(~ patient_id, ncol = 7)
# For each group defined above, set the plot dataset to that subset
# and then print the resulting plot
d_ply(df, (.group), function(df) plot %+% df, .print = TRUE)
Regards,
Hadley
Good point - I always forget about that.
Hadley