enlarge_raster: Enlarge a Color Matrix

Description Usage Arguments Examples

View source: R/enlarge_raster.R

Description

This is a convenient wrapper of colorRampPalette to enlarge a color matrix or raster.

Usage

1
enlarge_raster(x, n = c(10, 10), row_first = TRUE, space = "rgb")

Arguments

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 c(10, 10).

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 space parameter used by colorRampPalette. It can be "rgb" (default) or "Lab".

Examples

 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)

plothelper documentation built on July 2, 2020, 4:03 a.m.