Description Usage Arguments Examples
The function is a wrapper of
scales::alpha
. While the latter
only works on vectors, the former
can combine a matrix of colors and
a matrix of alpha values as long as the two
have the same numbers of rows and
columns.
1 | raster_alpha(color, alpha, result = "raster", res = 144)
|
color |
a matrix of colors, a
raster or an image read into R by
|
alpha |
either a single value (e.g., 0.4)
or a matrix of alpha values. The matrix
should have the same numbers of rows
and columns as |
result |
if it is "raster", the result will
be a matrix which can be used by
|
res |
the |
1 2 3 4 5 6 7 8 | # A color matrix
co=c("red", "yellow", "green", "blue")
co=rbind(co, co, co)
# An alpha matrix
alp=c(1, 0.6, 0.3, 0.1)
alp=rbind(alp, alp, alp)
# Now combine the two
result=raster_alpha(co, alp)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.