The colors package defines two classes,
color.coding
and
color.coded.pair
,
and several symbolic names for color values. See
the bottom of the page for an example of how the
classes can be used.
Class Name: color.coding
col
option of the plot
command.pch
option of the plot
command. The
default value is 1.color.coding
class.An object of the color.coding
class
consists of a logical vector v
and a scalar
color
. The idea is that this information will be used to
display some other pair of vectors in a particular color. The
color
scalar will be passed to the col
option in a plot
command, and points for which the
logical vector is true will be plotted in the associated color.
color.coding
class.y
as
function of x
. The standard optional arguments to the
plot routine can be used (but the ones that affect color should
probably be avoided).An object of the color.coded.pair
class represents a plottable two-dimensional object (given by the
vectors x
and y
) along with a list,
ccl
, of color.coding
information. The plot
routine for a color.coded.pair
produces a scatter plot with
specified points colored according to the scheme specified by the
color.coded.pair
objects. By passing
around lists of color.coded.pair
objects,
we can ensure that related points on distinct graphs are colored
consistently.
The package also defines symbolic names for certain color values to help ensure that a consistent color-code is used throughout a project. Currently, the list of defined colors is:
theta <- (0:360)*pi/180 x <- cos(theta) y <- sin(theta) xp <- x > 0 yp <- y > 0 colors <- list(color.coding(xp&yp, 2), color.coding(xp&!yp, 4), color.coding(!xp&yp, 6), color.coding(!xp&!yp, 8)) plot(color.coded.pair(x, y, colors)) plot(color.coded.pair(theta, x, colors)) plot(color.coded.pair(theta, y, colors), xlab='angle in radians', ylab='sine', main='colored sine')