# Re: symbols in pairs()

Christian Keller (ckeller@aicos.com)
Fri, 30 Jan 1998 10:32:15 +0100

>> I would like to make a scatterplot matrix (i.e. pairs()) in which
>> different subsets of the data are shown with different symbols.
>> Specifically, for each scatterplot, I want to plot one subset of
>> the data with an open circle and the other subset with a filled
>> circle. How would one do this?

There are (at least) two possible solutions. You can use pairs() with
the panel argument or splom() form trellis library (see examples below).

## Example:
iris.df <- as.data.frame.array(iris, col.dims=2)
names(iris.df)[5:6] <- c("flower", "variety")

> iris.df[1:5,]
Sepal L. Sepal W. Petal L. Petal W. flower variety
1 5.1 3.5 1.4 0.2 1 Setosa
2 4.9 3.0 1.4 0.2 2 Setosa
3 4.7 3.2 1.3 0.2 3 Setosa
4 4.6 3.1 1.5 0.2 4 Setosa
5 5.0 3.6 1.4 0.2 5 Setosa

## Solution 1 (using pairs)
subset <- iris.df\$variety=="Setosa"
pairs(iris.df[,1:4], panel=function(x,y){
points(x[subset],y[subset], pch=1)
points(x[!subset],y[!subset], pch=16)})

## Solution 2 (using splom)
trellis.device(motif)
superpose.symbol <- trellis.par.get("superpose.symbol")
superpose.symbol\$pch <- c(16,1,2,3,4,5,6)
trellis.par.set("superpose.symbol", superpose.symbol)
splom(~ iris.df[,1:4], groups=iris.df\$variety=="Setosa",
panel=panel.superpose)

I hope this helps.
-- Christian
----------------------------------------------------------
Christian Keller Tel: +41 61 686 98 81
AICOS Technologies AG Fax: +41 61 686 98 88
Efringerstrasse 32 email: ckeller@aicos.com
CH-4057 Basel, Switzerland Web: http://www.aicos.com/
----------------------------------------------------------