Creating corporate colour palettes for ggplot2
@drsimonj here to share how I create and reuse corporate color palettes for ggplot2.
You’ve started work as a data scientist at “drsimonj Inc” (congratulations, by the way) and PR have asked that all your Figures use the corporate colours. They send you the image below (coincidentally the Metro UI colors on color-hex.com):
You want to use these colours with ggplot2 while also making your code reusable and flexible.
Outline and setup
We’re going to create the following:
- Named vector of hex codes for the corporate colors
- Function to access hex codes (in 1)
- Named list of corporate color palettes (combinations of colors via 2)
- Function to access palettes (in 3)
- ggplot2-compatible scale functions that use the corporate palettes (via 4)
Load the ggplot2 package and set a default theme to setup:
Start with color
Continue reading →