Skip to contents

Function that returns a palette or a set of individual colors within the palette.

Usage

scale_dc(
  aesthetic = NULL,
  ...,
  colorOffset = 0,
  reverseOrder = FALSE,
  displayNames = FALSE,
  darkenPaletteForTextGeoms = FALSE,
  useColorBlindPalette = FALSE,
  colorBlindPaletteName = "safe"
)

Arguments

aesthetic

Color aesthetic in 'fill', 'color', 'base', 'text','border','background', or 'grayedOut'

...

single or vector of colors

colorOffset

Offsets the ordering of the palette. E.g., colorOffset = 2 would move the first two colors to the end of the palette, starting at the 3rd color.

reverseOrder

Logical, TRUE reverses the default order of the palette. Default FALSE. Applied after colorOffset.

displayNames

TRUE if you want to see the names of each color. Default FALSE.

darkenPaletteForTextGeoms

Logical, if TRUE then the palette ill be darkened slightly.

useColorBlindPalette

Logical, if TRUE uses color blind friendly palette instead of style.

colorBlindPaletteName

Name of colorblind friendly palette. Use `cols4all::c4a_palettes()` for available palettes.

Value

hex codes of a subsetted palette

Examples

library(styles)

# Single valued colors: Basic elements
scale_dc('text') # Text (a dark gray)
#> [1] "#646464"

# Palettes: Used in scale fill or scale color below
scale_dc('color', displayNames = TRUE) # All accent colors (line colors)
#>      blue       red     green    purple    orange    yellow   purple1      gray 
#> "#7a9ba3" "#b27a6d" "#8ea199" "#9289a1" "#b69a83" "#bba988" "#988f90" "#767d86" 
scale_dc('fill',  displayNames = TRUE) # All main colors (fills)
#>      blue       red     green    purple    orange    yellow   purple1      gray 
#> "#a8d3de" "#f2a896" "#c2dcd1" "#c7bbdb" "#f7d2b4" "#fee6ba" "#d0c3c5" "#a2acb7" 
scale_dc('fill', 3)                    # 3 fills
#> [1] "#a8d3de" "#f2a896" "#c2dcd1"
scale_dc('fill', 'red', displayNames = TRUE) # Just a red fill
#>       red 
#> "#f2a896" 

# Color blind friendly palette override
scale_dc('color', useColorBlindPalette = TRUE)
#>  [1] "#88CCEE" "#CC6677" "#DDCC77" "#117733" "#332288" "#AA4499" "#44AA99"
#>  [8] "#999933" "#882255" "#661100" "#6699CC"