7

Data visualizations: Choosing colors with purpose

 3 years ago
source link: https://uxdesign.cc/data-visualizations-choosing-colors-with-purpose-4a672ac0215a
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Data visualizations: Choosing colors with purpose

Streams of smoke in various different colors.
Streams of smoke in various different colors.
Photo by Paweł Czerwiński on Unsplash

Visualizations can provide a much more impactful and intuitive sense of data than viewing it in its raw form. There are a plethora of visualization tools and chart types that help convey data in different ways, many of which are particularly useful for specific types of data. While a lot of thought may go into choosing a visualization type, it’s also important to take it a step further and consider the colors used as well.

The Impact of Color

Why use it at all?

Beyond making visualizations aesthetically pleasing, color can also serve other purposes. One such purpose is adding dimensionality in a world constrained by three-dimensional space. While three-dimensional projections of higher dimensional objects such as the tesseract exist, the concept is very difficult for the human brain to wrap itself around. As a result, we’re forced to get a bit creative. Color (along with size, shapes, and more) allows for conveying an additional dimension of data in a non-spatial manner.

A color map, sometimes also referred to as a palette, is an array of different color values used within a particular visualization or group of visualizations as a broader theme. Limited only by the number of colors a monitor can display (~16.8 million based on the RGB color model), there is no shortage of different possible color maps. However, not all color maps should be considered viable candidates for data visualizations. As an example, let’s take a look at the below heat map (the x and y axes are irrelevant):

A heat map chart using a color map with a wide range of colors that is difficult to interpret.
A heat map chart using a color map with a wide range of colors that is difficult to interpret.
Photo by Michael Waskom from the Seaborn “Choosing color palettes” Tutorial

Is it immediately obvious what value each color represents relative to the others? Using the exact same data with a different color map yields the following:

A heat map chart using a color map that makes it clear what the relative values are.
A heat map chart using a color map that makes it clear what the relative values are.
Photo by Michael Waskom from the Seaborn “Choosing color palettes” Tutorial

Even without having a legend to reference, which had been purposefully withheld from both pictures for the sake of this example, the second image provides a much clearer and intuitive sense of the relative differences in each color value. For those curious, you can view a side-by-side comparison of both images along with their legends in Seaborn’s “Choosing color palettes” tutorial by clicking here.

Color Maps for the Color Blind

The incorporation of intuitive color maps in data visualizations is an extremely useful tool, but has one major drawback: the information conveyed by the colors is lost to those who cannot distinguish between them. According to the Colour Blind Awareness Organisation (UK-based), approximately 8% of men and 0.5% of women worldwide have some form of color vision deficiency (CVD). Fortunately, certain scientifically derived color maps have been created which are able to maintain distinguishability across various different types of color blindness. Several such color maps are shown below with their corresponding CVD-adjusted perceptions.

A list of color maps that are friendly to people with color blindness and how they look to people with varying color vision deficiencies.
A list of color maps that are friendly to people with color blindness and how they look to people with varying color vision deficiencies.
Photo from “The misuse of colour in science communication” by Fabio Crameri, Grace E. Shephard, and Philip J. Heron

In addition to non-CVD vision, each of these color maps provides a logical and continuous scale for different types of color vision deficiencies, including complete color blindness. In contrast, visualizations using color maps that do not keep this information in mind are prone to causing confusion for CVD readers.

A rainbow color map and how it looks to people with various color vision deficiencies.
A rainbow color map and how it looks to people with various color vision deficiencies.

As can be seen in the rightmost color scale perception above (complete color blindness), use of a rainbow color map creates duplicate values at the opposite ends of the spectrum. Color maps that make use of nearly all colors in the visible light spectrum are frequently used but should largely be avoided for this exact reason.

Further Examples

Given the vast number of both colors and visualization types, an exhaustive list of recommendations for choosing colors with purpose is impractical. The following examples are intended to cover some of the most common errors made when using colors in visualizations.

Unnecessary use of colors

In some instances, the use of colors can detract from the overall value of a data visualization by conveying information where there is none. While the chart below does make use of a scientifically derived and CVD-friendly color map (viridis), its use is confusing and redundant given the existence of the x axis labels. This chart would be much easier to consume by changing the bars to a single color, dropping the legend, and changing the x axis title to “Brand” instead of “mpg” which is inaccurate.

A bar chart showing the average mpg for different auto manufacturers. The bars are colored according to the brand name of the manufacturer in alphabetical order.
A bar chart showing the average mpg for different auto manufacturers. The bars are colored according to the brand name of the manufacturer in alphabetical order.
Photo by AbdulMajedRaja from programmingwithr.com (link)

In defense of the original creator, the primary goal of the article this chart was sourced from revolved around manipulating color maps to fit data in different ways rather than necessarily creating a completely accurate chart. Nevertheless, this represents a prime example of adding unnecessary dimensionality to a data visualization via the use of colors.

Non-intuitive colors

Context matters. Using colors that have strong associations with particular values in a non-intuitive manner can also make visualizations confusing and harder to interpret. For anyone familiar with American politics, the following map of the results of the 2020 presidential election should look very wrong:

A map of the United States showing the outcome of the 2020 presidential election. States won by the Republican candidate shown in blue while states won by the Democratic candidate are shown in red.
A map of the United States showing the outcome of the 2020 presidential election. States won by the Republican candidate shown in blue while states won by the Democratic candidate are shown in red.
Photo created by me using 270towin.com

That gut reaction is in response to the associations of the Democratic party with the color blue and the Republican party with the color red. However, this map is technically 100% accurate given the legend. While this specific example is particularly extreme and unlikely to unintentionally occur, the general issue is something to be considered when creating visualizations.

Red and green only

Many visualizations that deal with displaying information in response to a “yes” / “no” or “support” / “oppose” question use a red and green color map like the chart below. In Western culture, these colors make intuitive sense given the association of “yes” / “support” / “up” with green and “no” / “oppose”/ “down” with red (side note: this dynamic is reversed in many Eastern cultures). With red-green color blindness being the most common form of color vision deficiency, however, the use of this color map strongly inhibits a sizable portion of the global population from being able to effectively interpret the visualization. A simple exchange of the color map to one that avoids CVD related issues would increase accessibility at no expense to the quality of the visualization.

A chart showing the percentage of Americans that support rejoining the Paris Climate Agreement split into four categories: All US adults, Democrats, Republicans, and Independents. Support is shown in green and opposition is shown in red.
A chart showing the percentage of Americans that support rejoining the Paris Climate Agreement split into four categories: All US adults, Democrats, Republicans, and Independents. Support is shown in green and opposition is shown in red.
Photo by Niall McCarthy from Statista (link) — original data from YouGov

Resources

Fortunately for data visualization creators, the open-source community has created a number of tools and resources for making the task much simpler. Several of these tools and resources are listed below:

  • Matplotlib: one of the most popular visualization libraries for Python, many different scientifically derived color maps come included
  • Seaborn: built on top of Matplotlib, this library includes some additional color maps and makes other styling methods a breeze
  • Colorbrewer: specifically focused on cartographic visualizations, this site allows for selecting different color maps with filtering options for only those that are CVD-safe and/or printer-friendly
  • Fabio Crameri: a collection of different color maps from one of the authors of the paper that inspired this article (see the Acknowledgements section below)
  • Colorgorical: a useful tool for creating color maps with unique parameters such as perceptual distance, name difference, pair preference, name uniqueness, and more
  • CCC-Tool: a tool for creating and exporting color maps with advanced functionalities such as specifying interpolation methods, color difference metrics, and optimizations

Acknowledgements: This article was largely inspired by “The misuse of colour in science communication” by Fabio Crameri, Grace E. Shephard, and Philip J. Heron which was graciously released under the Creative Commons Attribution 4.0 International License in the Nature Communications journal. For those seeking a deeper, more scientific approach to this topic, I highly recommend reading their paper.

0*RgxBX_Oyalodkdt0?q=20
data-visualizations-choosing-colors-with-purpose-4a672ac0215a
The UX Collective donates US$1 for each article published on our platform. This story contributed to World-Class Designer School: a college-level, tuition-free design school focused on preparing young and talented African designers for the local and international digital product market. Build the design community you believe in.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK