How to Create Beautiful Color Palettes in R



How to Create Beautiful Color Palettes in R

This tutorial describes how to generate color palettes in R. Color is crucial for elegant data visualization. You will learn the basics for using the power of color and, we describe an R package and an online tool for generating beautiful color schemes.



Contents:

Understanding color wheel

The color wheel helps you visualize the relationships that colors have to one another. The wheel uses three primary colors, red, yellow and blue, spaced evenly apart. Blending those colors creates the full color wheel.

The wheel is divided into pie slices which has the following components:

  • hue (true color): On the wheel below, the hue is four rings out of the center.
  • tints: correspond to the colors toward the center of the wheel (= hue + white color)
  • shades: corresponds to the ring of colors on the outside of the hue ( = hue + black color)

Color wheel

You can select colors for your palette anywhere in the wheel with any saturation of color, but make sure that it contrasts and projects well. There is a bit of a science to creating a pleasing palette (Duarte 2008).

Use the power of color

Here, we defined the basics that can help you to design great color palettes. We’ll use the R package colortools for displaying the different variations of colors.

  1. Monochromatic: Variations of the same color.
  2. Analogous: colors that are touching in the wheel creates narrow harmonious color scheme.
  3. Complementary: Colors from the opposite ends of the wheel provide the most contrast.
library(colortools)
analogous("#00AF71")

complementary("#005496")

To create a variation of the same color, you can use the function sequential(). It’s also possible to generate a color wheel for a given color by using the function wheel().

# Color wheel
wheel("steelblue", num = 12)

# Sequential colors
sequential("steelblue")

  1. Split Complementary: A variation of the complementary scheme that uses two colors on either side of a directly complementary color. These colors have high visual contrast but with less visual tension than purely complementary colors.
  2. Triadic: Three colors equally spaced around the color wheel create vivid visual interest.
  3. Tetradic or Square color scheme: Two pairs of complementary colors. This scheme is popular because it offers strong visual contrast while retaining harmony.
library(colortools)
splitComp("steelblue")

tetradic("steelblue")

square("steelblue")

Design your color scheme online

The online tool Colors Scheme Designer can be used:

colors scheme designer

Conclusion

This article presents color wheel and provides the basics for designing your own color palettes in R.

References

Duarte, Nancy. 2008. Slide:ology the Art and Science of Creating Great Presentations. Sebastopol, CA: O’Reilly Media. http://www.worldcat.org/search?qt=worldcat_org_all&q=0596522347.



Version: Français





No Comments

Give a comment

Want to post an issue with R? If yes, please make sure you have read this: How to Include Reproducible R Script Examples in Datanovia Comments