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]]
On 10/27/08, erwann rogard <erwann.rogard at gmail.com> 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?xyplot(y~x2|x1+which,data=make.groups(dataframe1, dataframe2)) -Deepayan
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
> the example below does not work. (i know it's not supposed, but it makesit> 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)par is a base graphics command, and doesn't work with grid/lattice graphics. While it is possible to merge grid and base graphics using for example the gridBase package, I suspect what you want is to draw two lattice plots on the same figure. For this, you need to read up on viewports, and try an example like this: pushViewport(viewport(layout=grid.layout(2,1))) pushViewport(viewport(layout.pos.row=1)) topplot = xyplot(Sepal.Length ~ Petal.Length | Species, data = iris) print(topplot, newpage=FALSE) upViewport() pushViewport(viewport(layout.pos.row=2)) bottomplot = xyplot(Sepal.Width ~ Petal.Width | Species, data = iris) print(bottomplot, newpage=FALSE) popViewport(2) See also section 5.5 in Paul Murrell's book ('R Graphics'). Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}