[R] Arrays of Trellis plots

baptiste auguie ba208 at exeter.ac.uk
Mon Oct 27 19:25:39 CET 2008


Hi,


You could use the grid package to place treillis objects in any custom  
layout you want, for example
(inspired by Paul Murrell's R graphics book < http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html 
  > fig 5.22),



library(grid)
library(lattice)

df <- data.frame(x=rnorm(100), y=rnorm(100))
df2 <- data.frame(x <- rnorm(100), y=runif(x))

p <- xyplot(y~x, data=df)
p2 <- xyplot(y~x, data=df2)

pushViewport(viewport(x=0.25, width = 0.5, height = 0.8, angle = 0,
name = "leftvp"))
grid.rect(gp = gpar(col = rgb(43/255, 140/255, 190/255)))
print(p, newpage=F)
upViewport()
pushViewport(viewport(x=0.75, width = 0.5, height = 0.8, angle = 0,
name = "rightvp"))
grid.rect(gp = gpar(col = rgb(43/255, 140/255, 190/255)))
print(p2, newpage=F)
upViewport()


Hope this helps,

baptiste

On 27 Oct 2008, at 18:13, erwann rogard wrote:

> hello,
>
> the example below does not work. (i know it's not supposed, but it  
> makes it
> clear what i'm trying to achieve)
>
> par(mfrow=c(2,1))
> xyplot(y~x2|x1,data=dataframe1,pch=20)
> xyplot(y~x2|x1,data=dataframe2,pch=20)
>
> i know i could probably merge the two datasets and do something like
> xyplot(y~x2|x1+dataset,data=merged)
>
> any other suggestion?
>
> thanks.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag



More information about the R-help mailing list