7 Replies Latest reply on Nov 14, 2018 11:49 AM by Carol Ling

    Advanced treemap grouping

    Alex Martell

      I am trying to visualise wine data in a treemap according to the following hierarchy:

      1. Country of origin (one colour per country, e.g. red for France)
      2. Region (NO IMPACT on colour)
      3. Age of the wine (shade varies by the age of the wine, e.g. darker red for older French wines)


      I have managed to get the treemap pretty close to what I need, but not quite:


      The problem with the above chart is that, for instance with French wines, the chart is varying the shade of red by region, which I do not want.  I want the shade to vary ONLY by wine age.


      The reason is because it becomes confusing when, for instance, a wine with age 11 in one region has the same shade as a wine of age 3 in another region, for instance





      What I’m trying to get is that ALL the French wine with age 11 have the same shade, all the French wines of age 7 have the same shade etc.


      Any help greatly appreciated. Tableau file attached. Thanks!

        • 2. Re: Advanced treemap grouping
          Jonathan Drummey

          Hi Alex,


          I'm going to do a short response right now because I'm getting ready to head out for the 2016 Tableau Conference tomorrow.


          Sometimes things are harder to do in Tableau because they aren't very useful visualizations (based on the research). Of the pre-attentive attributes (position, angle/direction, size, shape, lightness, saturation, hue, etc.), hue is the one that we have the hardest/worst time making comparisons with. For example is it peach, orange-pink, pink-orange, or coral??. In the case of a view like this we're being asked to make exact comparisons across hues for the same lightness (i.e. identify all the 7 year wines) and that's challenging to do. I'd first suggest focusing in on the questions you are trying to ask of the data and potentially use different views that are more appropriate to the questions, for example if you did a set of bars with Region & Country on Rows and the Age as a dimension on Columns with your continuous measure on Columns as well. Then the bar length would be your measure and users could get a sense of how much each country produced by the length of the bars. You'd lose some of the part-to-whole relationship but that could be in a simpler treemap or bubble plot on a dashboard that is then tied by highlight and filter actions to the bars worksheet.  


          If you really want to go for having everything in one chart I just did a post at Two Sequential Color Palettes on the Same Map: Coloring by a Dimension and a Measure | Drawing with Numbers on how to do this for two palettes on a red/blue political map, the last couple of paragraphs of the post describe and link to another post that talks about how it could be done for an arbitrary number of colors by creating your own custom palette.



          1 of 1 people found this helpful
          • 3. Re: Advanced treemap grouping
            Alex Martell

            Thanks Jonathan for taking the time to respond.


            I hear you about the importance of questioning whether the visualisation is a useful one or not.


            My question though is more of a technical Tableau question, can the visualisation I am trying to get (because it works very well for me and I'm the ultimate user of this chart in this case) be accomplished on Tableau and if so, how.


            I am very close to what I want to get, for instance in the California section of the chart (see below), the chart is working perfectly.



            Even though you're right in that I can't know for certain what age wines are in the lower right hand corner, I know that they are significantly older than the ones in the lower middle half of the chart, and that the wines in the upper left are somewhere in between in terms of age.


            Which is exactly what I need and I am thrilled with it.  For me it beats looking at a table or bar charts (all of which I've tried) hands down, keeping in mind too that the chart is dynamic so all I have to do if I want to know the exact age of a wine is hover over it to reveal the tooltip that shows the exact age.



            The problem arises when I include other regions of the USA.


            It seems to me the problem is not with the visualisation per se, but with the fact that Tableau tries to attribute different shades to different regions of the USA, which I do NOT want.


            I want it to vary the hue of the blue ONLY with wine age, not with region, because the white borders provide more than enough separation (and actually for me the perfect separation) between wines from different regions.



            In the chart above, Tableau shows Oregon wines a little lighter purely because they are from a different state than California.  That is what I do NOT want.


            I want the hues to follow EXACTLY the same pattern as California, in other words to vary ONLY because of wine age, NOT region.


            And I'm fairly desperate to find a way to get Tableau to group them in regions only through the white separators, as it is already doing, but without affecting the colour, which should only vary based on wine age.

            • 4. Re: Advanced treemap grouping
              Jonathan Drummey

              I just put together an example using mocked up data (based on Superstore) using a three-hue (red, blue, purple) custom color palette that I'd built when working on the aforementioned post ...in this case the palette is based on Tableau's own palettes (so the lightness is the same for each color and has 20 steps, you could get away with something that had fewer steps if you want. There are two table calculations, the Normalized Age normalizes the age values to a number between 1 and 20 across all the data, then the Age Color returns a value that plots correctly in the color ramp:


              Screen Shot 2016-11-05 at 4.28.28 PM.png


              Note that what is on the Color shelf is not a set of discrete pills but a single continuous pill (the Age Color calculation) and the multiple colors are coming from the custom color palette.


              v10.0 workbook is attached.



              3 of 3 people found this helpful
              • 5. Re: Advanced treemap grouping
                Matt Lutton



                Your dedication to helping others is admirable, but please, go enjoy Austin!!!


                Looking forward to seeing you in the next couple of days at TC16!

                • 6. Re: Advanced treemap grouping
                  Alex Martell

                  Hi Jonathan - this is heading in the right direction and is hugely helpful, thanks tons, I can see how the grouping in your file is not affecting the age colouring, which is what I need.


                  I'll see if I can reconstruct with my data set following your example and expand to include more than 3 colours.


                  Thanks again!

                  • 7. Re: Advanced treemap grouping
                    Carol Ling

                    Hi Jonathan, I found your solution fascinating! And your concept behind gradient coloring helped me out in my viz project.

                    I have one little questions, would you mind explaining a bit about how you created the 'normalized age'? What's the mathematical approach you used to scale the age between 1-20? 


                    Thanks a lot!