Description Usage Arguments Details Value See Also Examples
Map numeric (scalars, vectors, matrices) into colors, (optionally) using a specified color map.
1 |
x |
Something numeric (vector, matrix). |
map |
The color map to use (as created by |
outlier |
Color for values outside the map domain, or NULL to generate an error in case of such values (see Details). |
... |
Arguments passed to |
Values in x outside the domain of map cause either an error (if outlier=NULL) or a warning (otherwise).
Something of the same size as x. May be character (RGB) or integer
(palettes) depending on the color map used. Dimensions and dimnames are preserved.
makecmap. Also, as.raster and level.colors have similar functionality.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | x <- y <- 1:50
mat1 <- outer(x, y)
## several ways of visualizing the matrix mat1:
plot(col(mat1), row(mat1), col = cmap(mat1), pch = 16)
cimage(x, y, zcol = cmap(mat1))
colorgram(x = x, y = y, z = mat1)
## treatment of out-of-domain values
map <- makecmap(0:100, colFn = greyscale)
x <- y <- -10:10
mat2 <- outer(x, y, "*")
## Not run:
## Values outside the domain of "map" generate an error...
plot(col(mat2), row(mat2), col = cmap(mat2, map), pch = 15, cex = 2)
## ... unless we specify "outlier", but this still generates a warning
plot(col(mat2), row(mat2), col = cmap(mat2, map, outlier = 'red'), pch = 15, cex = 2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.