getPalette: Hex color vector in a palette

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Get a vector of hex colors (lower case characters) or a hex color function factory from a designated (named) palette.

Usage

1
2
3
4
5
getPalette(palette, n = NULL, show = FALSE, mode = c("na.fill",
  "no.fill", "repeat.fill"), ...)

named_pal(palette, n = NULL, show = FALSE, mode = c("na.fill",
  "no.fill", "repeat.fill"), ...)

Arguments

palette

Character, the palette name (case insensitive).

n

Numeric, the length of color vector. Default NULL, which indicates that the function will return a function to generate color vectors.

show

Logical, whether display the palette. Default FALSE. If n is NULL, then show will be ignored.

mode

Character, either "na.fill", "no.fill", or "repeat.fill". If n > max number of colors of the palette, then

  • na.fill: Default choice. NAs will be used to fill the output vector

  • no.fill: the output color vector will not be suplemented

  • repeat.fill: the color vector will be repeated to fill the length

...

Other arguments to pass to the function. E.g., theme='Atlas' can be passed to excel_new_pal() when palette='excel_new'; or direction = -1 can be passed to tableau_color_pal when palette='tableau10'. You can always set alpha to change the transparency of the output vector.

  • if alpha is between [0, 1] and is double, the [0, 1] alpha scale will be applied;

  • if alpha is integer (e.g., 2L, 155L, ...), the [0, 255] alpha scale will be applied.

Details

getPalette (named_pal) generally gets hex value of the colors in a designated palette. The palettes include Aetna palette, palette in packages RColorBrewer, ggthemes and viridis. You can run palettes.info to check the palettes information.
The following palettes are available:

Aetna palttes
'qual'

'aetclassic_green', 'aetclassic_blue', 'aetclassic_teal', 'aetclassic_cranberry', 'aetclassic_orange', 'aetclassic_violet', 'aetnew_violet', 'aetnew_teal', 'aetnew_cranberry'

'div'

'aetdiv_violet', 'aetdiv_teal', 'aetdiv_cranberry'

'seq'

'aetdiv_violet', 'aetdiv_teal', 'aetdiv_cranberry'

RColorBrewer palettes
'div'

'BrBG', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral'

'qual'

'Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3'

'seq'

'Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd'

ggthemes palettes
  • normal:

    'qual'

    'calc', 'economist', 'economist_white', 'excel_line', 'excel_fill', 'excel_new', 'few', 'fivethirtyeight', 'gdocs', 'pander', 'stata', 'stata1', 'stata1r','statamono','hc', 'darkunica','wsj', 'wsj_rgby', 'wsj_red_green', 'wsj_black_green', 'wsj_dem_rep', 'colorblind'


  • tableau (see tableau_color_pal):

    'regular' ('qual')

    "tableau10", "tableau20", "tbl_colorblind", "tbl_seattle_grays", "tbl_traffic", "tbl_miller_stone", "tbl_superfishel_stone", "tbl_nuriel_stone", "tbl_jewel_bright", "tbl_summer", "tbl_winter", "tbl_gnorte", "tbl_rdbubw", "tbl_pupkgy", "tbl_hue_circle", "tbl_classic10", "tbl_classic10_medium", "tbl_classic10_light", "tbl_classic20", "tbl_classic_gray5", "tbl_classic_colorblind", "tbl_classic_traffic_light", "tbl_classic_pugy6", "tbl_classic_pugy12", "tbl_classic_gnor6", "tbl_classic_gnor12", "tbl_classic_burd6", "tbl_classic_burd12", "tbl_classic_cyclic"

    'ordered-diverging' ('div')

    "tbl_orbu_div", "tbl_rdgn_div", "tbl_gnbu_div", "tbl_rdbu_div", "tbl_rdbl_div", "tbl_gdpu_div", "tbl_rdgngd_div", "tbl_sunset_sunrise_div", "tbl_orbuwi_div", "tbl_rdgnwi_div", "tbl_gnbuwi_div", "tbl_rdbuwi_div", "tbl_rdblwi_div", "tbl_orbu_light_div", "tbl_temperature_div", "tbl_classic_rdgn", "tbl_classic_rdbu", "tbl_classic_rdbl", "tbl_classic_area_rdgn", "tbl_classic_orbu", "tbl_classic_gnbu", "tbl_classic_rdwign", "tbl_classic_rdwibl", "tbl_classic_orwibu", "tbl_classic_rdwibl_light", "tbl_classic_orwibu_light", "tbl_classic_rdwign_light", "tbl_classic_rdgn_light"

    'ordered-sequential' ('seq')

    "tbl_bugn_seq", "tbl_blue_light", "tbl_orange_light", "tbl_blue", "tbl_orange", tbl_green", "tbl_red", "tbl_purple", "tbl_brown", "tbl_gray", "tbl_gray_warm", "tbl_bute", "tbl_orgd", "tbl_gngd", "tbl_rdgd", "tbl_classic_green", "tbl_classic_gray", "tbl_classic_blue", "tbl_classic_red", "tbl_classic_orange", "tbl_classic_area_red", "tbl_classic_area_green", "tbl_classic_area_brown"


  • solarized (see solarized_pal):

    'div'

    'solarized','solarized_red', 'solarized_yellow', 'solarized_orange','solarized_magenta','solarized_violet', 'solarized_blue', 'solarized_cyan', 'solarized_green'

viridis palettes
'seq'

'megma', 'inferno', 'plasma', 'viridis', 'cividis'

grDevices palettes
'qual'

'rainbow'

'seq'

'terrain', 'topo', 'heat'

'div'

'cm'

Value

Author(s)

Yiying Wang, wangy@aetna.com

See Also

The palettes majorly come from RColorBrewer, ggthemes, and viridis. You can also refer to colorspace to build your own palette.
Refer to data:palettes.info to check built palettes info. And you can use the generalized parser function hex_colors to get hex colors more conveniently.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
## Get the entire Aetna classic green palette
f <- getPalette("aetclassic_gre")  # returns a function factory
f(8)  # returns first 8 colors

## Get 7 colors from palette 'terrain'
named_pal("terrain", 7)

## End(Not run)

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