Working with Colors



July 26, 2022

View slides in full screen | Run the code yourself


  • Color Palettes
    • Pre-Defined Color Palettes: Viridis
    • Pre-Defined Color Palettes: Brewer
    • {rcartocolor}
    • {scico}
    • {ggsci} and {ggthemes}
    • {nord}
    • {MetBrewer}
  • Customize Palettes
    • Customize Existing Palettes
  • Create New Palettes
    • Create Sequential Palettes
    • Create Diverging Palettes
    • Create Any Palette
  • HCL Spectrum
    • Evaluate HCL Spectrum
  • Test Your Palettes
    • Emulate CVD


  • use categorical palettes for qualitative data
    • e.g. scale_*_discrete() and scale_*_manual() for custom options
    • e.g. scale_*_viridis_d and scale_*_brewer() for pre-defined options
  • use sequential or diverging palettes for quantitative data
    • e.g. scale_*_gradient() or scale_*_gradient2() for custom options
    • e.g. scale_*_viridis_c and scale_*_distiller() for pre-defined options
  • various packages provide palettes incl. scale_* components
    • e.g. {rcartocolors}, {scico}, {ggsci}, {ggthemes}, {nord}
  • those and even more packages return palettes as vectors
    • modify and supply them to scale_*_manual() and scale_*_gradientn()
  • use after_scale to modify and recycle color scales


  • Open the script exercises/06_colors_ex1.qmd (or the .rmd).
  • Create a similar visualization as the one in the folder exercises/7-1-bikes-jitter

→ Solution