[R] How to create a list of trellis objects for grid.arrange()
Duncan Mackay
dulcalma at bigpond.com
Sun Oct 30 05:26:10 CET 2016
Hi
I did not have a look at this when it was sent as I thought it dealt with
ggplot objects
If you have trellis objects (check by str())or ?class) try printing them
print(p2, position = (c(0,0,1,0.5), more =T)
print(p1, position = (c(0,0.5,1,1), more = F)
The only other way that I can think of is using viewports
? grid::viewports
If it is base graphics then ? layout may fix it
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Agustin Lobo
Sent: Thursday, 27 October 2016 23:58
To: r-help at r-project.org
Subject: [R] How to create a list of trellis objects for grid.arrange()
Given
require(raster)
require(sp)
require(gridExtra)
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
p1 <- spplot(r)
p2 <- spplot(r)
I would like to plot the equivalent to
grid.arrange(p1,p2,ncol=1,nrow=2)
but keeping the trellis objects p1 and p2 within one single object (as
in practice I have many objects generated within a for() loop).
The following used to work:
ps <- c(p1,p2)
grid.arrange(ps,ncol=1,nrow=2)
but does not work any more.
How should I combine p1 and p2 into one single object that would be
accepted by grid.arrange?
Thanks
--
Agustin Lobo
aloboaleu at gmail.com
______________________________________________
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