Palettes

There are a number of color palettes that the sdcoe package makes available.

Main colors

Shades

Categorial

Sequential

Equidistant

Diverging

How to use colors

Stand-alone

You can use colors directly by calling them directly with their name (or position):

sdcoe::palette_sdcoe_main["midnight_blue"]
#> midnight_blue 
#>     "#005488"

This outputs a named vector. Wrap it with unname() to remove the name (you need that when using manual scales).

unname(sdcoe::palette_sdcoe_main["midnight_blue"])
#> [1] "#005488"

Or use directly double brackets:

scale_fill_manual(values = c(
  palette_sdcoe_main[[1]],
  palette_sdcoe_diverging[[5]],
  palette_sdcoe_main[[4]]
))

Palettes

Palettes can be used directly through the scale_* functions, which takes the right palette by default:

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  geom_point() +
  scale_color_discrete() +
  theme_sdcoe_print()

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  geom_point() +
  scale_color_ordinal() +
  theme_sdcoe_print()

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Petal.Width)) +
  geom_point() +
  scale_color_gradientn() +
  theme_sdcoe_print() +
  theme(legend.key.width = unit(1,"cm"))