Skip to contents

Creates a discrete color scale for ggplot2 using predefined CSIDS color palettes.

Usage

scale_color_cs(..., palette = "primary", direction = 1)

Arguments

...

Additional arguments passed to ggplot2::discrete_scale()

palette

Name of color palette to use (default: "primary"). Options: "primary", "warning", "posneg"

direction

Direction of color palette: 1 for normal, -1 for reversed (default: 1)

Value

A ggplot2 discrete color scale

See also

Other csstyle_ggplot2: scale_fill_cs(), theme_cs()

Examples

library(ggplot2)

# Default primary color scale
ggplot(mtcars, aes(x = mpg, y = hp, color = factor(cyl))) +
  geom_point() +
  scale_color_cs()


# Use warning palette
ggplot(mtcars, aes(x = mpg, y = hp, color = factor(cyl))) +
  geom_point() +
  scale_color_cs(palette = "warning")