# WVPlots and Color Controls

Published:

I've put a new release of the WVPlots package up on CRAN. This release adds consistent palette and/or other color controls to most of the functions in the package.

WVPlots was originally a convenience package just for us; we put it up on CRAN in the hopes that other people might find our plots to be useful as well. Because it was just for us, we tended to hard-code in our preferred color choices. For example, for plots that color-code by group, I tend to prefer the Brewer Dark2 palette because it is

• saturated,
• color-blind friendly for a small number of classes,
• gray-scale printing friendly (though not photocopy-friendly),
• reasonably perceptually uniform.

This last property is important when you don't want the viewer to prefer certain groups over others. Of course, you may have other desiderata for your visualization needs. Sequential or diverging palettes are useful when you do wish to imply an order or ranking among groups; sequential palettes can also be color-blind friendly over a larger number of classes. If perceptual uniformity is important, then the viridis palettes are analytically designed to be perceptually uniform and color-blind friendly (and apparently print-friendly as well). And when you are reporting results and wish to "tell stories" with your data---that is, visually draw your audience to the conclusion you wish them to reach---then hand-tuning your color palette to draw users to pay attention to important groups rather than to less relevant ones can be crucial.

The Brewer family of palettes, developed by cartographer Cynthia Brewer in the early 2000s, includes a variety of qualitative, diverging, and sequential palettes, originally designed for map making. Since the perceptual issues around making legible maps are similar to the issues around making legible data visualizations, I find the Brewer palettes incredibly useful for data science, and WVPlots reflects this preference. If you prefer other palettes, it is also possible to "turn off" the Brewer palettes and use ggplot2's default color scheme, to use viridis, or to manually specify the color palette.

You can see some examples of the palettes and color controls in use, in my official announcement of the new version release on the Win-Vector blog.

Here are more interesting references on color, color palettes and their uses:

colorbrewer2.org: A super-useful website for browsing the Brewer palettes. Provides the color designations in Hex, RGB, and CMYK, along with advisory information on whether palettes are color-blind friendly, print friendly, photocopy friendly, and LCD friendly.

Designing Better Maps: A Guide for GIS Users: Professor Brewer's textbook on map design. Primarily for cartographers, of course, but possibly of interest to data scientists who need to analyze, visualize, and present geographically-based data. Includes a couple of chapters on the use of color, and an appendix about the colorbrewer website.

David Nichols's Coloring for Colorblindness site includes an online tool to help non-colorblind people visualize what various palettes look like to viewers with various types of colorblindness. It also includes links and suggestions on various colorblind-friendly palettes.

A discussion and video about the development of the viridis palettes by Stéfan van der Walt and Nathaniel Smith, the palette designers. The viridis palettes were originally developed for Python's matplotlib library.

Storytelling with Data: A Data Visualization Guide for Business Professionals: Cole Nussbaumer Knaflic's excellent text on effective communication via data visualization. Includes numerous tips on the use of color to guide your narrative.

Happy plotting!

Tags:

Categories: