colorAccording2: Transform numeric values to color-gradient

View source: R/colorAccording2.R

colorAccording2R Documentation

Transform numeric values to color-gradient

Description

This function helps making color-gradients for plotting a numerical variable. It requires the package 'RColorBrewer' being installed from CRAN. Note : RColorBrewer palettes were not integrated here, since they are not continuous.

Usage

colorAccording2(
  x,
  gradTy = "rainbow",
  nStartOmit = NULL,
  nEndOmit = NULL,
  revCol = FALSE,
  alpha = 1,
  callFrom = NULL
)

Arguments

x

(character) color input

gradTy

(character) type of gradeint may be 'rainbow', 'heat.colors', 'terrain.colors', 'topo.colors', 'cm.colors', 'hcl.colors', 'grey.colors', 'gray.colorsW' or 'logGray'

nStartOmit

(integer) omit n steps from begining of gradient range

nEndOmit

(integer or "sep") omit n steps from end of gradient range, if nEndOmit="sep" 20 percent of initial grades will be removed to obtain 'separate' ie non-closing color-circles/gradients eg with rainbow

revCol

(logical) reverse order

alpha

(numeric) optional transparency value (1 for no transparency, 0 for complete opaqueness)

callFrom

(character) allow easier tracking of message(s) produced

Value

This function returns a character vector (of same length as x) with color encoding

See Also

cut

Examples

set.seed(2015); dat1 <- round(runif(15),2)
plot(1:15,dat1,pch=16,cex=2,col=colorAccording2(dat1))
plot(1:15,dat1,pch=16,cex=2,col=colorAccording2(dat1,nStartO=0,nEndO=4,revCol=TRUE))
plot(1:9,pch=3)
points(1:9,1:9,col=transpGraySca(st=0,en=0.8,nSt=9,trans=0.3),cex=42,pch=16)

wrMisc documentation built on Nov. 17, 2023, 5:09 p.m.