Description Usage Arguments Value Author(s) See Also Examples
Get colors from a named palette or other formats
1 2 3 |
palette |
A palette name with/without number of colors, or a vector of color names, or a hex color value.
|
unlist |
Logical, whether unlist the result. Defalt TRUE. |
... |
Other arguments to pass to the function, e.g., alpha, theme, .... |
palette is col2rgb-compatible: a list of hex colors (lower case).
palette is named_pal-compatible: a list of hex colors (lower case) (when
in 'palette_name(3)
' format) or a list of functions (when in
'palette_name()
' format).
Note: If unlist
=TRUE, the function will try to unlist the output list.
Yiying Wang, wangy@aetna.com
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.