color.key | R Documentation |
Similar to legend
but takes up less space.
color.key( col = NULL, pch = NULL, labels = NULL, breaks = NULL, digits = 2, cex = 0.75 * par("cex") )
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 |
cex |
character expansion factor. |
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.
Tom Minka
color.plot
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.