What is Polygon?
Polygons are 2-dimensional shapes. They are points connected by straight lines and they enclose an area. Polygons are categorized into different types depending on the number of their sides and the corresponding angles.
Tableau’s Polygon chart type is an incredibly powerful tool to create something unique such as Alex Varlamov’s 3D work. However, you don’t have to think big to make individual polygon visualizations.
A great example is Sebastián Soto Vera’s visualization – the #6th week of #MakeoverMonday. He used polygon to cover the upper part of the background image and got this amazing illusion.
Let’s take a closer look
Sebastián predefined the dots for each data point (each Birth year) by the ’order’ column in the dataset.
There are two extra points at the first(1905) and last year(2019). They were necessary to close the shape area.
Because he already had the Polygon_Id from the dataset, the process in Tableau was quick and easy. Let’s put the [Birth year] and the [% of your life the US has been at war] to the Columns and Rows. Set the Mark type to Polygon and use the [Order] on the Path Mark.
What if we define the Polygon_IDs in Tableau?
Let me show you my idea.
I already used a similar technique at my previous projects like at Bar Code Viz.
We have only 2 columns, one for [Birth year] and one which defines the [% of your life the US has been at war].
Creating a line chart from this data is simple in Tableau, but to get a shape to cover the view in the image above a bit more complex. We have to connect the points of the line chart with the points of the upper straight line. Hence, we need to define the points of the upper straight line to get this shape.
I union the data twice, because now I can refer to the points of line chart and the points of the upper straight line. The first Table refers to the line chart while the second refers to the upper straight line.
- PATH
IF [Table Name]=’Table’ THEN 1
ELSEIF [Table Name]=’Table1′ THEN 2
END
Let’s create the chart.
- The X axis will be easy, I use the [Birth year]
- Y axis – the first table (Path =1) uses the [% of your life the US has been at war] and it draws the line chart while the second table (Path=2) uses the max value of the [% of your life the US has been at war] and I added + 0.5 to get the same ratio that Sebastián did.
CASE MIN([Path])
WHEN 1 THEN AVG([% of your life the US has been at war])
WHEN 2 THEN MAX({ FIXED :MAX([% of your life the US has been at war])})+0.5
END
We have all of the points on the view. The last thing left to do is to set the Polygon, but before we need to tell Tableau how to connect those points. The missing piece of the visualizaion is the Polygon_ ID calculation. The calculation helps Tableau tell the right order.
Here, the first table uses the [Birth year] from 1905-2019 while the dummy points of the line get the [Birth year]*(-1).
- Polygon_ID
IF [Path]=1 THEN [Birth year]
ELSE [Birth year]*(-1)
END
Let’s set the Polygon Mark type and use the background image.
Here we are.
Summary
Thank Sebastian for inspiring me with his visualization. Keep in mind that Tableau has endless possibilities to create the same thing. If you are interested in reading more step by step instructions how to create incredible visualization using polygons, check Klaus Schulte’s blog here: https://vizjockey.com/
I hope you enjoyed reading. I am happy about your feedback, you can reach out to me on twitter or in this comments section
The post Polygons are everywhere! appeared first on DataViz.LoVe.