Description Usage Arguments Examples
View source: R/enlarge_raster.R
This is a convenient wrapper of
colorRampPalette
to enlarge
a color matrix or raster.
1 | enlarge_raster(x, n = c(10, 10), row_first = TRUE, space = "rgb")
|
x |
a color matrix or raster. It should have at least 1 row and 1 column with no NAs. |
n |
a vector with 2 numbers. If it has 1 number,
the number will be repeated twice. The two numbers
indicate how many colors you will get in the result per
row and per column. Default is |
row_first |
enlarge rows first or enlarge columns first? Default is TRUE. The results are almost the same, so you do not need to change this. |
space |
the |
1 2 3 4 5 6 7 8 9 10 11 | library(ggplot2)
# the original matrix
m=matrix(c(
"red", "yellow", "green",
"blue", "purple", "cyan",
"black", "orange", "grey"), byrow=TRUE, nrow=3)
# enlarge the matrix
mm=enlarge_raster(m, c(15, 15), space="Lab")
ggplot()+xlim(0, 10)+ylim(0, 5)+coord_fixed()+
annotation_raster(mm,
xmin=0, xmax=10, ymin=0, ymax=5, interpolate=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.