raster_alpha {plothelper} | R Documentation |
Combine a Matrix of Colors and a Matrix of Alpha Values
Description
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.
Usage
raster_alpha(color, alpha, result = "raster", res = 144)
Arguments
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 |
Examples
# 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)
[Package plothelper version 0.1.9 Index]