[R] multiple plots in R

Felipe Carrillo mazatlanmexico at yahoo.com
Mon Nov 24 04:05:31 CET 2008


Here's one way with ggplot2

library(ggplot2)
p <- qplot(mpg, wt, data=mtcars)
vplayout <- function(x, y)
viewport(layout.pos.row=x, layout.pos.col=y)
grid.newpage()
pushViewport(viewport(layout=grid.layout(3,3)))
print(p, vp=vplayout(1,1))
print(p, vp=vplayout(1,2))
print(p, vp=vplayout(1,3))
print(p, vp=vplayout(2, 1))
print(p, vp=vplayout(2, 2))
print(p, vp=vplayout(2, 3))
print(p, vp=vplayout(3, 3))

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA




--- On Sun, 11/23/08, Suyan Tian <stian at mail.rockefeller.edu> wrote:

> From: Suyan Tian <stian at mail.rockefeller.edu>
> Subject: [R] multiple plots in R
> To: r-help at r-project.org
> Date: Sunday, November 23, 2008, 6:19 PM
> Hi, I just try to draw multiple plots in one page using R, I
> used par command. For example I have 7 plots, but instead of
> arranging them in the default way
> 
> plot1    plot2  plot3
> plot4   plot5   plot6
> plot7
> 
> I want them in this order
> plot1   plot2  plot3
> plot4   plot5  plot6
>             plot7
> 
> Could somebody tell me how to do this, please? Thanks so
> many.
> 
> 
> Suyan
> 
> ______________________________________________
> 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.



More information about the R-help mailing list