color.plot: Plot subgroups as colored points

View source: R/colour.R

color.plotR Documentation

Plot subgroups as colored points

Description

Like plot and text.plot but colors according to a third variable.

Usage

color.plot(object, ...)

Arguments

x, y

numeric vectors of the same length.

z

a numeric vector or factor, same length as x and y.

labels

a character vector of labels, same length as z. If NULL, cases are plotted as points (default).

axes

If FALSE, no axes are plotted (but there may still be a key).

key

If FALSE, no key is plotted.

add

If FALSE, a new plot is made. If TRUE, points or labels are added to the existing plot.

nlevels

an integer. If z is numeric, it is color-coded using this many levels. (If z is a factor, color-coding follows the factor levels.)

color.palette

a vector of colors, arbitrary length, or a function with integer argument which generates a vector of colors (e.g. YlGnBu.colors). Used if col is not specified. If shorter than the number of levels, colors will be recycled and the plotting symbol will change.

col

a vector of colors, as in a call to plot. Used to explicitly set the color of each point.

pch.palette

a vector of plotting symbols, arbitrary length. If labels=NULL, the plot symbol will rotate through these when there aren't enough colors.

pch

a vector of plotting symbols, as in a call to plot. Used to explicitly set the symbol of each point.

digits

the number of digits to use in the color key when z is numeric.

bg

the background color

mar

figure margins (see par). If not specified, appropriate margins will be chosen automatically, which will not necessarily match the current value of par("mar").

Details

Each (x,y) point is plotted with a color determined by z. If z is a factor, each factor level is in a different color. If z is numeric, then it is color-coded by assigning each quantile a different color.

Despite the name, this function can also make plots using different symbols instead of colors. For example, if color.palette=1 then all points will be black but use different symbols.

When labels != NULL, the result is equivalent to text.plot with colors.

If key=TRUE and there is more than one color or symbol on the plot, a key is displayed at the top of the figure.

Value

A plot is produced.

Note

This function sets the figure margins permanently, so that you can draw on the color plot. Unfortunately, this also means future plots will use the same margins, until you change them with par("mar").

Author(s)

Tom Minka

See Also

color.plot.data.frame,color.plot.loess,color.plot.glm,color.plot.knn,color.plot.tree,YlGnBu.colors

Examples


# See the examples for color.plot.data.frame


paulemms/datamining documentation built on March 1, 2023, 4:01 p.m.