The guest post by Tableau Zen Master Matt Chambers is featured as part of Election Month.
A lot of my previous work has been centered around custom maps or mapping techniques within Tableau. I've always been fascinated with FiveThirtyEight's custom electoral-college cartogram used in its 2016 election forecast. This type of cartogram was created in response to critiques about the use of geographic maps to show election data.
So here's how I did it in Tableau. I happened to see a post that shows several different cartograms that are currently being used for the election. In this post, you will see that the SVG (scalable vector graphic) for the different cartograms is there. I took the SVG, converted it to a shapefile, and used the Alteryx Gallery tool to convert it to a CSV. I did some manual matching to get the state abbreviations paired with the polygons as well.
Once I had the CSV, I was able to build it in Tableau. Here's how it's done.
1. Download the file for the polygons.
2. Open Tableau and connect to the data source. In this case, I am joining another data set so that I can color the states by the candidates' chances of winning each state. You will need to make sure your data set has a state abbreviation to join the polygon file to your data set.
3. Drag X to Columns and Y to Rows, making sure the aggregation is AVG. Choose polygon as the mark type and drag Polygon ID to Detail and Point ID to Path.
4. Drag Y to the Rows again making sure the aggregation is AVG. Create a dual axis, synchronize the axes, and change the mark type to text. Drag the State Abbreviation to the Text Marks card.
5. Drag the measure you'd like to color by to the Color Marks card. Turn on the color borders.
6. Hide the headers and remove gridlines.
And there you have it! Feel free to download the workbook and comment with questions. I'm really excited to see how people use this for the #ElectionViz gallery.