How To Use Colors In Your Visualizations

This article is by Patrik Lundblad and originally appeared on the Qlik Blog here: https://blog.qlik.com/how-to-use-colors-in-your-visualizations

 

It’s time to get back to my favorite topic in visualization – how to best use color. I’ve written about it before in two of my previous posts, which you can read by clicking here and here. But, for this post, I’m going to go into a bit more detail on some tips and tricks that you can use.

 

So, why use colors in a visualization? The normal best practice is to not use colors unless it adds something to the visualization. But, at the same time, we live in a world where every day we see colorful visualizations that aim to draw our attention to them. Therefore, chances are that your visualizations might be ignored if just go by best practice and keep your colors plain or minimal.

That’s why many times I see people just add colors to visualizations without much thought, hoping to grab attention. It’s what I usually call a “Skittles” visualization, and it’s ultimately often distracting. You can see an example below, using colors to denote car model, of which there are many.

The colors don’t add much additional or distinguishable information; rather, the colors might just confuse people. Let’s instead look at some effective ways to add colors!

Color By A Category

If you want to add color to convey additional information to a visualization, then find a category in your data that represents the values you are plotting. Then, for each value, assign a category. This might sound harder than it is. But, if you have some type of hierarchy in your data, then you usually already have a category you can assign.

For example, if we look at geography, you often have a hierarchy. Such as Continent->Country->State. So, if you have countries plotted in a chart, you could then color those countries by the Continent category. The same thing applies for products: They often belong to a product category. In the example below, I’ve taken the same “Skittles” visualization above, and, instead of showing color per car model, we are now looking at the category Country.

As a comparison, on the right you can also see what the visualization looks like with only one color. Use of a single color may be good, depending on your purpose with the visualization. But, with multiple colors and a category (in this instance, Country), you get that extra information which might lead to more insights, such as Japan making lightweight cars.

Color By Order

In the text above, I used what’s called a nominal category, but you can also have an ordinal one. If you can’t remember the difference between them, check out my blog post on data attributes for an explanation.

Here’s the short version, though: With an ordinal category, I can sort the values inside a category into an order, such as small, medium and large. Knowing there is an order to the values we can use a sequential color scale instead of one that is qualitative. As you can see below, the sequential one contains colors of decreasing and increasing intensity, from left to right.

If you’re interested in more color scales like the one above, I recommend Color Brewer as a great inspiration. There are also many other sites out there where you can create your own scales based on color input.

Now that we know that the data is ordinal, and that we can use a sequential scale, we can go ahead and add an ordinal category to our visualization, such as Year.

From the visualization above, we can see which car models came out which year, which tells us which ones are newer or older. But, that’s not all. If we know, for example, the most recent value (say, Year, 2019), we can denote it using a standout color and denote the older values (say, Years, 2018, 2017, 2016) with gradients of a more muted color, decreasing in intensity the further back you go. The standout color becomes a means to highlight what’s the most important value, with the others kept as context. See the below graph.

In this example, you can see how sales are doing per month for the latest year; however, you can also compare sales per month from previous years. And, with a sequential scale (that is, a scale that changes its intensity – in this case, gray), you can more easily see which years are closer in time.

Highlight Something Interesting

In the last example, the red highlight color assisted the viewer of a visualization to know what was most important in the visualization. So, in the case where there is no appropriate category to color, then maybe there are some interesting data points that should stand out compared to the rest.

In this example, I’ve picked a couple of Swedish car models that I want to highlight, using a mix of colors so that I can identify each model. I’m also using a neutral color (gray) for the rest of the models to make the ones that are interesting stand out.

What Colors To Use?

Lastly, as a rule of thumb, make sure the colors you assign to values are appropriate. See the questions below to help you determine that.

  • Are you using colors that are accessible to your users? Or, will there be issues with a red and a green color used in the same scale for people who have red-green color blindness.
  • Where will the colors be used? On a computer screen, colors can be vibrant and crisp. But, as soon as you show it on a projector, chances are that the colors will be washed away against the white background.
  • What’s the ambient lighting like? In a dark room, then a dark background with light colors in the visualization is preferable. The reverse is true in a bright room.

Also, make sure to agree upon which colors to use for what value or category. I prefer to have a color palette where I’ve assigned colors to a given category, such as Year, or a color for our products compared with those of our competitors. It makes it easier to know which color to use, and it also assists people consuming our visualizations to know what the colors means.

Conclusion

These are my favorite methods to use colors in visualizations. They make the visualizations look more interesting, while, at the same time, add something to the understanding of the visualization.