Advanced Tableau Color Palettes

Advanced Tableau color palettes

Good Tableau visualization relies heavily on good use of color. Tableau provides a selection of default color palettes, which are a pretty solid place to start; however, there’s plenty of room to do better!

Last year, I wrote about how to create your own custom color palettes in this blog post. Today, we’ll zoom in on one particular type of custom color palette – ordered gradients – and look at three advanced use cases: Better diverging colors, more levels of detail in color, and dynamically assigned categorical colors.

First of all: In this post, I won’t provide instructions for how to implement custom color palettes – I’ll assume you already know how. If you don’t, go check out the custom palettes blog post for a full walk through.

Today we’re going to be looking at the ordered sequential color palette.

(A quick note: I’m using ordered-sequential here because it doesn’t require a center point. If your data has a clear center point, such as a diverging palette centered at 0, use ordered-diverging instead – the back end works the same).

To create it, add a new palette to your preferences.tps file with a type tag of “ordered-sequential”. You can add as many colors as you want, in any order – Tableau will make them into a gradient color palette that transitions smoothly through the list.

The example palette in the image lists three colors (a navy blue, dull blue, and light purple), and creates the following palette in Tableau:

These palette types give us a lot of flexibility in how to use colors in Tableau. Let’s dive into three use cases for custom sequential palettes!

1. Diverging Palettes with Less Grey

When you create a custom diverging palette in Tableau, the center of the divergence defaults to a very light grey.

Sometimes this is fine! But there can be issues – the light grey doesn’t always show up well on a light background (especially for scatter plots or other small marks), and if you have a lot of data clustered in the middle of the range, you get a lot of grey on your visual.

If the grey doesn’t work for you, don’t worry – we can improve it! By creating a custom palette with 3 colors, we can actually specify the middle color. In the example below, I’ve added a dull purple as my center color. (This is the actual color that you get when blending this red and blue).

The medium color I chose here may or may not work well for your viz. The best advice I can give you for advanced color palettes is this: Play around! What works well in one context and with one color scheme may be absolute garbage in another. Maybe your context works better with a very dark midpoint:

Or a lighter purple:

Use your judgement to figure out what’s best for your viz. As long as you select a color that’s some kind of blend of the two ends, you’ll eliminate the grey.

2. Add More Detail With Color

By default, Tableau chooses “white” as the blending color for any gradients you build in Tableau. It’s the end color of sequential palettes, and the middle color of diverging palettes. In the first use case, we looked at how to eliminate that white/grey from your palettes, which is a great first step! Sometimes, though, we want to do more than just “not grey” – we want to use the colors in a gradient to convey extra information.

The most common use of this can actually be seen in one of Tableau’s default palettes, “Temperature Diverging”. A third color, yellow, is added to represent “medium” values in the range.

Tableau only includes a few default palettes that use a multiple-color range, but don’t worry – we can make our own too! This works exactly the same as the first use case, so I won’t spend too much time on the details, but it’s probably one of the most common ways to actually use advanced color palettes.

Here are a couple of examples:

This palette is a variation of the one above, that replaces the green end value with a blue. It uses three colors (blue/yellow/red). The green that’s visible is created by Tableau’s default blending.

You may want to have more control over how the colors blend (especially to avoid getting unexpected fourth colors, like the green here). All you have to do is add additional color points to define the blend more specifically. This palette uses the same end and middle colors, but has 9 colors defined in the preferences file.

You have tons of options for these palettes here, and they’re a great way to add more information to your viz through the use of color. (One caveat: Don’t overdo it! Palettes with too many distinct colors often hurt more than they help. Limiting colors in a gradient to 3, plus intermediate blending colors, is typically a good idea).

3. Dynamically Define Categorical Colors

So far, we’ve seen two use cases for custom gradients that come up pretty frequently. Now, let’s get a bit more niche. This is a very specific use case, but it’s actually what inspired this blog post – it came up for me at work last week!

Here’s the situation: You have a bunch of categorical data that’s being shown on a chart, such as a line chart. I’ve made a Very Bad Chart ™, below, showing products from the Tableau Superstore data set. I’ve used the color-blind default palette to assign colors.

This is, obviously, a bad chart, and we should never show it to anyone ever. Luckily, in our use case we’ll only ever need to show a couple products at a time. (Maybe the user is picking products to compare, or other filters are in action). So that’s ok! However, this leads to a problem with our color coding.

If I assign colors like I have above, using a categorical palette, some of the colors will overlap or be very similar. That means that if the products selected happen to have similar colors – for example, chairs and tables – I get a chart that’s almost more useless than the original.

(Please don’t do this.)

Changing the colors doesn’t help, because I’ll still get combinations that don’t work. Even if I have enough colors to cover all of my products, some colors are still going to be similar enough to look bad. What I really want to do here is dynamically assign each category a color, so that each category shown gets a color that’s more or less distinct. This is not possible with categorical colors, because discrete colors have to be manually assigned during dashboard creation.

However, the problem isn’t impossible! We can use multi-color gradients and a helper field to make this work. Here’s how.

  1. First, set up a multi-color ordered sequential palette in your preferences file. You should ideally have at least as many colors as you might have shown at one time in your viz. (So if you’ll be showing a max of 3 categories, include at least 3 colors).

    Include as many extra color points as you need to make sure that you get transitions between colors that look good, instead of unpleasant greys – you might end up with your transition colors being used in the viz, so make sure you’re happy with them. I’m going to use the same blue/yellow/red palette I used in the previous use case.
  1. Next, we’ll create a continuous helper field to allow us to assign colors. Making this field continuous lets us stay completely dynamic with our color assignment – we can assign 2 colors or 5 colors just as easily.

    To create this field, we need to assign a unique value to each category, evenly distributed. The simplest way to do this using rank_unique. Since product will be a field in our view, we can keep this pretty simple:
  1. This calculated field should be continuous by default. If it’s not, right click it in the field list and convert it to continuous.

    Now we can apply the color helper field to the color shelf of the view. Then add “Product” (or your category) to the detail shelf. Right click the “Color Helper” pill and change “Compute Using” to “Product”. Tableau will change your color palette to a continuous option.
  1. Finally, let’s apply our custom color palette, and filter the view back down to a couple products.

Now we can see our dynamic color assignment in action. No matter how many products I select, I get a color palette that’s distributed across the range, which keeps my products as distinct as possible.

One more thing to add here: You’ll notice that the default legend has become entirely unhelpful. We’ll need to make a custom legend sheet here if you want to show one. I’ll do a deeper dive on how to do this in a future post, but here’s a quick snapshot of one method to do this:

  1. Create a new view with the same filters applied (link them across views, don’t just copy them).
  2. Add “Products” to the Rows shelf
  3. Add “Color Helper” to the color shelf, and set the “Compute Using” to “Product”.
  4. Change the marks type to “Shape”, and select the filled square.
  5. Edit sizing, spacing, and formatting as desired.

Let's keep in touch! New tips, tricks, and tutorials are posted about once a week - sign up to get them straight to your inbox!

I don’t spam! Read the privacy policy for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *