How To: FiveThirtyEight Electoral College Cartograms in Tableau

9/28/2016 Matt Chambers 0 Comments




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 their 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 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 mark card.



5. Drag the measure you'd like to color by to the Color mark.  Turn on the color borders.



6. Hide the headers, remove gridlines



Feel free to download the workbook and comment with questions.  I'm really excited to see how people use this for Tableau's election coverage.

0 comments:

Note: Only a member of this blog may post a comment.