I want to make a 2x2 plot on a single page, using stripplot() and boxplot(). I tried the following two alternatives with mfrow() and layout(), but none of them worked. library(lattice) par(mfrow=c(2,2)) boxplot(X1 ~ Y, data=tst1, horizontal=T, las=1) boxplot(X2 ~ Y, data=tst1, horizontal=T, las=1) stripplot(Y ~ X1, data=tst1) stripplot(Y ~ X2, data=tst1) par(mfrow=c(1,1)) nf <- layout(matrix(c(1,2,3,4), 2, 2, byrow=TRUE)) layout.show(nf) boxplot(X1 ~ Y, data=tst1, horizontal=T, las=1) boxplot(X2 ~ Y, data=tst1, horizontal=T, las=1) stripplot(Y ~ X1, data=tst1) stripplot(Y ~ X2, data=tst1) What happens is that the two plots with boxplot() appears on one page, and each stripplot() appears on a single page. If I use stripchart() instead of stripplot() things works as expected (a 2x2 plot on a single page). What to do to get a 2x2 plot using stripplot()? Thanks Lars [[alternative HTML version deleted]]
Hi Lars Stripplot is defunct in R 2.10 and following releases, so I wonder a bit why you would still insist on using it. Your code will not be compatible with newer R versions, so I suggest you use stripchart instead (and maybe update your R as well). Cheers Joris On Thu, Jun 17, 2010 at 9:27 AM, Lars Karlsson <larsmkarlsson.53 at gmail.com> wrote:> I want to make a 2x2 plot on a single page, using stripplot() and boxplot(). > I tried the following two alternatives with mfrow() and layout(), but none > of them worked. > > library(lattice) > par(mfrow=c(2,2)) > boxplot(X1 ~ Y, data=tst1, horizontal=T, las=1) > boxplot(X2 ~ Y, data=tst1, horizontal=T, las=1) > stripplot(Y ~ X1, data=tst1) > stripplot(Y ~ X2, data=tst1) > par(mfrow=c(1,1)) > > nf <- layout(matrix(c(1,2,3,4), 2, 2, byrow=TRUE)) > layout.show(nf) > boxplot(X1 ~ Y, data=tst1, horizontal=T, las=1) > boxplot(X2 ~ Y, data=tst1, horizontal=T, las=1) > stripplot(Y ~ X1, data=tst1) > stripplot(Y ~ X2, data=tst1) > > What happens is that the two plots with boxplot() appears on one page, and > each stripplot() appears on a single page. > > If I use stripchart() instead of stripplot() things works as expected (a 2x2 > plot on a single page). > > What to do to get a 2x2 plot using stripplot()? > > > Thanks > Lars > > ? ? ? ?[[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. >-- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
On Thu, Jun 17, 2010 at 12:57 PM, Lars Karlsson <larsmkarlsson.53 at gmail.com> wrote:> I want to make a 2x2 plot on a single page, using stripplot() and boxplot(). > I tried the following two alternatives with mfrow() and layout(), but none > of them worked. > > library(lattice) > par(mfrow=c(2,2)) > boxplot(X1 ~ Y, data=tst1, horizontal=T, las=1) > boxplot(X2 ~ Y, data=tst1, horizontal=T, las=1) > stripplot(Y ~ X1, data=tst1) > stripplot(Y ~ X2, data=tst1) > par(mfrow=c(1,1)) > > nf <- layout(matrix(c(1,2,3,4), 2, 2, byrow=TRUE)) > layout.show(nf) > boxplot(X1 ~ Y, data=tst1, horizontal=T, las=1) > boxplot(X2 ~ Y, data=tst1, horizontal=T, las=1) > stripplot(Y ~ X1, data=tst1) > stripplot(Y ~ X2, data=tst1) > > What happens is that the two plots with boxplot() appears on one page, and > each stripplot() appears on a single page. > > If I use stripchart() instead of stripplot() things works as expected (a 2x2 > plot on a single page). > > What to do to get a 2x2 plot using stripplot()?Unless there are good reasons to do so, it's best not to mix traditional and lattice (or other grid-based) graphics. You could (1) use traditional graphics functions boxplot() and stripchart() as you have already tried, or (2) use lattice functions bwplot() and stripplot(). To learn how to combine them in a single page, see ?print.trellis (par("mfrow") will not work). -Deepayan