color.key {mining}R Documentation

Add a thin key to the top of a plot

Description

Similar to legend but takes up less space.

Usage

color.key(col=NULL,pch=NULL,labels=NULL,breaks=NULL,digits=2,cex=0.75)

Arguments

col a vector of colors, one for each group. Assumed black if none given.
pch a vector of symbols, one for each group. If less than two distinct symbols are given, no symbols are put in the key.
labels a character vector giving the label of each group.
breaks a numeric vector of boundaries between groups.
digits number of digits to use for breaks.
cex character expansion factor.

Value

A thin bar is placed at the top of the plot, just inside the plotting area. The bar is divided into equal-sized lengths, colored according to col. If pch is given, that symbol is plotted in the center of each segment. If labels is given, each label is placed at the center of the corresponding segment, just above the plotting area (using mtext). If breaks is given, the boundary between segments is also labeled with a number.

Author(s)

Tom Minka

See Also

color.plot

Examples

data(iris)
y = as.numeric(iris$Species)
plot(Sepal.Width ~ Sepal.Length, iris,col=y,pch=y)
color.key(1:3,1:3,levels(iris$Species))

[Package Contents]