A wrapper around a variety of scale_color_-() / scale_fill_-() functions.

scale_color_add_on(
  aes = "color",
  variable = NULL,
  clrsp = NULL,
  clrp = NULL,
  clrp.adjust = NULL,
  color.trans = "identity",
  ...
)

Arguments

aes

Character value. Either 'color' or 'fill'. Denotes the used aesthetic.

variable

The variable that is mapped onto the denoted aesthetic or a character value - one of 'numeric', 'discrete'.

clrsp

Character value. The color spectrum of choice. Run confuns::all_color_spectra() to see all valid input choices.

(Ignored if variable is discrete)

clrp

Character value. The color palette of choice. Run confuns::all_color_palettes() to see all valid input choices.

(Ignored if variable is numeric)

clrp.adjust

Named character vector or NULL. If character, it adjusts the colors that are used to represent the groups. Names of the input vector must refer to the group and the respective named element denotes the color with which to represent the group.

color.trans

Character value. If the variable displayed by color is continuous (numeric) color.trans is given to argument trans of the respective scale_<aes>_*() function.

...

Additional arguments given to the respective function.

  • ggplot2::scale_<aes>_viridis_c(...): If variable is numeric and clrsp is one of 'cividis', 'viridis', 'inferno', 'magma', 'plasma'.

  • colorspace::scale_<aes>_continuous_sequential(...): If variable is numeric and clrsp is sequential.

  • colorspace::scale_<aes>_continuous_diverging(...): If variable is numeric and clrsp is diverging.

  • ggplot2::scale_<aes>_viridis_d(...): If variable is numeric and clrp is one of 'cividis', 'viridis', 'inferno', 'magma', 'plasma'.

  • ggplot2::scale_<aes>_greyscale(...): If variable is discrete and clrp is set to 'greyscale'.

  • ggplot2:.scale_<aes>_discrete(): If variable is discrete and clrp is set to 'default'.

  • ggplot2::scale_<aes>_manual(...): If variable is discrete.

Value

An unnamed list containing the ggproto object.

Details

If the specified clrp does not contain enough colors to cover the specified variable NULL is returned - which makes the call to ggplot2::ggplot() use the default ggplot2 color panel.

Examples

library(ggplot2)

ggplot(mtcars, aes(x = qsec, y = wt)) +
geom_point(aes(color = mpg)) +
scale_color_add_on(aes = "color", clrsp = "Reds 3")