number2color | R Documentation |
Each of the n
elements of a numeric vector is mapped onto one of the m
specified colors.
number2color(x, colors, ncol = 21, equidistant = TRUE, xmin = min(x), xmax = max(x))
x |
numeric vector of observations that should be mapped to colors |
colors |
an optional vector of colors (see Note for default colors) |
ncol |
number of colors |
equidistant |
if |
xmin |
minimum |
xmax |
maximum |
Elements of a numeric vector are binned using either an equidistant sequence (default) or sample quantiles. Each bin is associated with a unique color, so binning the observations is equivalent to mapping the numbers to colors. The colors
are input to the colorRampPalette
function to create a color palette with length specified by the ncol
argument.
Returns of vector of colors the same length as x
If colors
is missing, the default color palette is defined as
colors <- c("darkblue", rainbow(12)[c(9, 8, 7, 5, 3, 2, 1)], "darkred")
which is a modified version of the rainbow
color palette.
Nathaniel E. Helwig <helwig@umn.edu>
.bincode
is used to bin the data
x <- 1:100
xcol <- number2color(x)
plot(x, col = xcol)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.