| as_colorraster | R Documentation |
Helper function that converts numeric values to colors and returns a raster image. Useful for visualizing numeric matrices as color backgrounds.
as_colorraster(x, palette = hcl.colors(30), na.color = "white")
x |
A numeric vector or matrix containing values to be mapped to colors. |
palette |
A vector of colors used as the palette. By default,
|
na.color |
Color used for |
Values in x are rescaled to the range of the palette using
scales::rescale(), and each value is mapped to a corresponding
color. If x is a matrix, the resulting raster preserves the same
dimensions.
A raster object as produced by as.raster().
library(RGraphSpace)
# Convert the volcano matrix to a color raster
img <- as_colorraster(volcano)
plot(img)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.