Description Usage Arguments Value Examples
From given values, generate colors for plotting points or surfaces.
1 2 3 |
x |
vector of values to evaluate |
n |
number of unique colors to be used in the palette |
pal |
optional specification for a color palette; defaults to
|
zeroctr |
logical, should the color scale diverge to be symmetrical around zero? |
... |
further arguments passed to other methods |
ngrid |
number of grid cells in the matrix of values plotted
in |
Vector or matrix of color values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # generate data
x <- seq(-1.95, 1.95, length = 30)
y <- seq(-1.95, 1.95, length = 35)
z <- outer(x, y, function(a, b) a*b^2)
# color surface of perspective plot by 'z' value
ngrid <- prod(dim(z))
f <- surfcol(z, ngrid=ngrid, alpha=0.8)
persp(x, y, z, col=f, phi=30, theta=-30)
# color points by numeric values
plot(x, y[1:30], col=colvec(x))
# color points by factor values
trmt <- gl(3, 10, labels = c('Q', 'R', 'S'))
plot(x, y[1:30], col=colvec(rev(trmt)))
# divergent colors centered on zero
set.seed(21)
x <- (rbeta(99, 0.5, 1) - 0.15) * 100
par(mfrow=c(1,3))
plot(x, col=colvec(x))
plot(x, col=colvec(x, zeroctr=TRUE))
plot(x, col=colvec(pseudo_log(x), zeroctr=TRUE))
par(mfrow=c(1,1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.