[R] Changing layout in grid.arrange

Jim Lemon drjimlemon at gmail.com
Sat May 9 02:38:01 CEST 2015


Hi Roy,
If this helps, you can get the layout like this:

split.screen(figs=matrix(c(rep(0,5),rep(0.5,10),rep(1,5),
 rep(seq(0.8,0,by=-0.2),2),rep(seq(1,0.2,by=-0.2),2)),ncol=4))
for(scr in 1:10) {
 screen(scr)
 par(mar=c(0,0,0,0))
 plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1),
  axes=FALSE,xlab="",ylab="",type="n")
 box()
 text(0.5,0.5,scr)
}
close.screen(all=TRUE)

Jim


On Sat, May 9, 2015 at 12:53 AM, Roy Mendelssohn - NOAA Federal
<roy.mendelssohn at noaa.gov> wrote:
> Hi All:
>
> I am doing something very similar to the the example in the grid.arrange package:
>
> require(ggplot2)
> plots = lapply(1:10, function(.x) qplot(1:10,rnorm(10), main=paste("plot",.x)))
> require(gridExtra)
> do.call(grid.arrange,  plots)
>
>
> If you run this, the layout is 4 rows and 3 columns with graphs 1-3 going across. What I would like instead is for the layout to have 2 columns and 5 rows, with graphs 1-5 going down the first column, graphs 6-10 going down the second column but almost everything I have tried has failed.  Any help appreciated.
>
> -Roy M.
>
>
> **********************
> "The contents of this message do not reflect any position of the U.S. Government or NOAA."
> **********************
> Roy Mendelssohn
> Supervisory Operations Research Analyst
> NOAA/NMFS
> Environmental Research Division
> Southwest Fisheries Science Center
> ***Note new address and phone***
> 110 Shaffer Road
> Santa Cruz, CA 95060
> Phone: (831)-420-3666
> Fax: (831) 420-3980
> e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/
>
> "Old age and treachery will overcome youth and skill."
> "From those who have been given much, much will be expected"
> "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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