A colour map is a mechanism for associating colours with data.
It can be regarded as a function, mapping data to colours. The command colourmap
creates an object representing
a colour map, which can then be used to control the plot commands
in the spatstat package. It can also be used to compute the
colour assigned to any data value.
The argument col
specifies the colours to which
data values will be mapped. It should be a character vector
whose entries can be interpreted as colours.
Exactly one of the arguments inputs
and breaks
must be specified by name.
If inputs
is given, then it should be a vector or factor,
of the same length as col
. The entries of inputs
can be
any atomic type (e.g. numeric, logical, character, complex) or factor
values. The resulting colour map associates the value inputs[i]
with the colour col[i]
.
If breaks
is given, then it determines intervals
of the real number line
which are mapped to each colour. It should be a numeric vector,
of length at least 2, with entries that are in increasing order.
Infinite values are allowed. Any number in the range
between breaks[i]
and breaks[i+1]
will be mapped to the
colour col[i]
.
The result is an object of class "colourmap"
.
There are print
and plot
methods for this class.
Some plot commands in the spatstat package accept an object
of this class as a specification of the colour map.
The result is also a function f
which can be used to compute
the colour assigned to any data value.
That is, f(x)
returns the character value of the colour assigned
to x
. This also works for vectors of data values.