[R] several car scatterplots on one graph

cryan at binghamton.edu cryan at binghamton.edu
Thu Oct 14 06:17:13 CEST 2010


R version 2.11.1 on WinXP

How do I get 3 scatterplots with marginal boxplots (from the car 
package) onto a single plot?

I have a data frame called bank

> dim(bank)
[1] 46  5

head(bank)

     x1    x2   x3   x4 pop
1 -0.45 -0.41 1.09 0.45   0
2 -0.56 -0.31 1.51 0.16   0
3  0.06  0.02 1.01 0.40   0
4 -0.07 -0.09 1.45 0.26   0
5 -0.10 -0.09 1.56 0.67   0
6 -0.14 -0.07 0.71 0.28   0

library(car)
par(mfrow=c(2,2))

# following lines may be wrapped badly--sorry

with(bank, scatterplot(x1,x2,groups=pop, reg.line=FALSE, 
smooth=FALSE, boxplots="xy", reset.par=FALSE))

with(bank, scatterplot(x1,x3,groups=pop, reg.line=FALSE, 
smooth=FALSE, boxplots="xy", reset.par=FALSE))

with(bank, scatterplot(x1,x4,groups=pop, reg.line=FALSE, 
smooth=FALSE, boxplots="xy", reset.par=FALSE))

I have tried various permutations of the reset.par=  option: all 
three lines FALSE, all 3 lines TRUE, the first TRUE and the others 
FALSE, vice versa, etc. And always I get just one scatterplot showing 
up on the device at a time, and occupying the whole thing.

Thanks.

--Chris Ryan
SUNY Upstate Medical University
Binghamton Clinical Campus



More information about the R-help mailing list