Description Usage Arguments Examples
View source: R/shading_raster.R
The function is a simple wrapper of
scales::col_numeric
.
The function creates a matrix of colors
that can be used to draw a shading rectangle.
There are 2 ways to use the function, see
the following parameters.
1 2 3 4 5 6 7 8 |
nr |
method 1 to use
this function is to use |
nc |
see |
middle |
see |
palette |
two or more colors used to make shading colors. |
mat |
see |
FUN |
the default NULL makes the colors
distributed in a linear way. However, |
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Use method 1.
r=shading_raster(nr=31, nc=60, middle=c(10, 55),
palette=c("darkorange", "red", "purple"))
ggplot()+xlim(0, 8)+ylim(0, 6)+
annotation_raster(r, xmin=-Inf, xmax=Inf,
ymin=-Inf, ymax=Inf, interpolate=TRUE)
# Use method 2.
r=matrix(c(
1, 2, 3, 4, 5, 6, 7, 8,
1, 2, 3, 4, 5, 6, 7, 8,
1, 1, 1, 1, 1, 1, 1, 1),
nrow=3, byrow=TRUE)
r=shading_raster(mat=r, palette=c("green", "blue"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.