getHexPal: Generalized color values parser

Description Usage Arguments Value Author(s) See Also Examples

Description

Get colors from a named palette or other formats

Usage

1
2
3

Arguments

palette

A palette name with/without number of colors, or a vector of color names, or a hex color value.

  • col2rgb-compatible arguments, either color names, hex color strings, or positive integer for palette()[i].

  • named_pal-compatible character arguments, in a "palette(n)" format.

unlist

Logical, whether unlist the result. Defalt TRUE.

...

Other arguments to pass to the function, e.g., alpha, theme, ....

Value

Note: If unlist=TRUE, the function will try to unlist the output list.

Author(s)

Yiying Wang, wangy@aetna.com

See Also

getPalette

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Not run: 
## Get a hex vector based on col2rgb-compatible palette
getHexPal(c("red", "yellow"))  # return
# [1] "#ff0000" "#ffff00"
getHexPal("red", alpha=200)  # feed alpha to ... with rgb()
# [1] "#ff0000c8"
hex_colors(2L, alpha=200)  # returns palette()[2L] with alpha=200
# [1] "#ff0000c8"

## Get a hex vector based on a hex value
getHexPal("#fff")  # return
# [1] "#ffffff"

## Get a hex vector based on named_pal-compatible palette
getHexPal("terrain(4)")  # return
# [1] "#00a600" "#e6e600" "#ecb176" "#f2f2f2"
## equivalent to
hex_colors("terrain", n=4)  # or the currying form
hex_colors("terrian")(4)

getHexPal(c("terrain(2)", "magma(2)"), unlist=FALSE)  # returns
# [[1]]
# [1] "#00a600" "#f2f2f2"
#
# [[2]]
# [1] "#000004" "#fcfdbf"

getHexPal("terrain")  # returns the function named_pal("terrain")

## End(Not run)

madlogos/asesvis documentation built on June 26, 2019, 12:18 a.m.