Whenever most of us see the Polygons mark type in a Tableau tutorial, we very quickly find the close button of our browser tabs. Are they really so evil? Let’s tame them!
Have you heard of the Datasaurus or Anscombosaurus? It is this 142 point plot first created by Alberto Cairo and showcased in his article. He designed it to further the point famously shown by Anscombe’s quartet: data visualization is useful and essential to really understand what’s going on in your data.
Let’s use Cairo’s underlying dataset to understand how polygons work in Tableau. I went ahead and did some of the manual work, so you don’t have to. I took all 142 points and went through them one-by-one, assigned them to a sub-polygon and gave them a number. It’s basically reverse engineering a connect-the-dots coloring book. This is the resulting dataset’s structure:
Polygon ID will mark our individual shapes. Point ID will mark the order in which the dots will need to be connected. Plot_X and Plot_Y will mark the coordinates of the individual points.
Alright let’s get cooking. Let’s open up Tableau and use our dataset. Let’s put the Plot_X pill onto our Columns shelf and Plot_Y onto the Rows. If we now turn aggregation of measures off, we should have ourselves the outlines of our dinosaur.
All we need to do from here, is change the Mark Type to Polygons, bring our Polygon ID onto Color and then Point ID to Path and this is what we should see.
The polygons are not in the right order, but all we have to do to fix that is rearrange the color order in the color legend by dragging and dropping the categories.
Play a bit with the colors and here’s the end result, our happy little datasaurus:
See, polygons are in fact really cute! (As long as you have the point coordinates for them)