Learn R Programming

tectonicr (version 0.4.6)

tectonicr.colors: Colors for input variables

Description

assigns colors to continuous or categorical values for plotting

Usage

tectonicr.colors(
  x,
  n = 10,
  pal = NULL,
  categorical = FALSE,
  na.value = "grey",
  ...
)

Value

named color vector

Arguments

x

values for color assignment

n

integer. number of colors for continuous colors (i.e. `categorical = FALSE``).

pal

either a named vector specifying the colors for categorical values, or a color function. If NULL, default colors are RColorBrewer::brewer.pal() (categorical = TRUE) and viridis::viridis() (categorical = FALSE).

categorical

logical.

na.value

color for NA values (categorical).

...

optional arguments passed to palette function

Examples

Run this code
val1 <- c("N", "S", "T", "T", NA)
tectonicr.colors(val1, categorical = TRUE)
tectonicr.colors(val1, pal = stress_colors(), categorical = TRUE)

val2 <- runif(10)
tectonicr.colors(val2, n = 5)

Run the code above in your browser using DataLab