Using colors can be a powerful way of making visualizations prettier and more effective. As there is an abundance of colors, color systems, and corresponding resources, choosing colors wisely requires some restraint, as well as background knowledge on how colors can be defined, selected, and combined.
This chapter aims to boost our color-related skills by introducing some related tools provided by R and R packages. More specifically:
This chapter provides a colorful primer on the following topics:
- distinguishing between colors and color palettes;
- distinguishing between different types of color palettes;
- knowing various ways of defining colors (by their names, HEX codes, or RGB values);
- finding R packages that provide colors and functions for dealing with color;
- creating custom color palettes for specific purposes (e.g., a particular type of graph) or audiences (e.g., for people with color-vision impairments);
- using color palettes (e.g., when creating visualizations in base R or ggplot2).
In the following sections, we first introduce some essential concepts (e.g., the distinction between colors and color palettes, as well as different types of color palettes), before showing various ways of finding, defining, and using colors in R:
Overall, this appendix is likely to render your future life in R much more colorful.