A few days ago, one of our clients contacted our hotline because he was struggling with double colouring when building a treemap. It’s true that it can be a bit tricky to get Tableau to do exactly what you want with double colouring, especially when we talk about treemaps. To know about the basics of double colouring, have a look at this Tableau article.
Double Colouring Made Easier
In this article, we’re going to discover two tricks to make Tableau double colouring smarter and easier. I had a play around and came up with two solutions to achieve our goal:
- The step-by-step, easy-but-unknown Tableau way
- The smart workaround
The Step-by-Step, Easy-but-Unknown Tableau Way
For this example, I created a simple treemap showing the breakdown of my category and sub category sized by sales: I can easily change Tableau default colours; however, If I add another colour on my subcategory, Tableau automatically assigns back the default green/orange/blue shades and not the gradient of the colour I picked (have a try with the Superstore data if you have not noticed this Tableau phenomenon thus far). That’s annoying, especially if you realize that you have to manually change the colour of each of the sub elements of the treemap! Before I actually spent some time on it, I thought that this extreme example was the only way (treemap drilled down up to the product level): So, how to proceed? The first step is to create the treemap before changing the colours. The second step is to sort the most granular dimension by the ascending value of the measure you’re using (if you do not sort, the colours will be assigned by the alphabetical order, which will result in a weird and meaningless colour distribution): Why ascending? Because when we assign a colour palette, Tableau will set the lighter shade on the first dimension and continues gradually up to the latest. If you sort by descending order, the first dimension in each category will be the highest value but will be coloured in the lightest shade of the palette you chose. The third and last step (*** here is the trick ***) is to edit the colour legend and CTRL + select the category/ sub category colour fields before selecting the new colour palette and clicking assign palette: You can then repeat the process for each category. In this example, it takes three steps instead of 30 when assigning the colour palette! Tada. Our first good looking, customized and sorted Tableau treemap: If you do not want to go through all these steps or are not fan of treemaps, have a look at our second solution.
The Easy Workaround
Treemaps are useful if your goal is to show the breakdown of the whole for different dimensions according to a specific measure. In our examples: sales for each category and sub category. But you can also build a segmented bar chart, which keeps the “breakdown of the whole” concept of the treemap while being easy to understand. You see easily the biggest/smallest of both category’s and subcategory’s sales: The idea there is to “fake” the double colouring with a dual axis. In the example, we use one axis to colour the dimension (here our category) and the second axis to gradually colour the measure (here our sales). Then, by setting up a low transparency % on the sales colouring (in our second axis), we can achieve a double colouring.
- Create your chart (anything that can be dual axis here can work) and colour it by one of your dimensions. If it makes sense, sort it by ascending/descending order of the measure you’re displaying (here our category and sub category dimensions are sorted by descending order):
- Duplicate it and make it a dual axis:
- On the Marks card, select the axis colored by Sales. Then, click the Color box and choose the Grey Sequential palette. Also, on the Color box, set the Transparency to 30% (you can make it lighter or darker by adjusting the transparency). It should look like this:
Feel free to share your ideas, tricks and the way you’re using double colouring in Tableau.