Re: [R] Multiple plots in a single page and stripplot()

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Thu, 17 Jun 2010 15:08:29 +0530

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



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. Received on Thu 17 Jun 2010 - 09:41:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jun 2010 - 10:20:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive