Data Viz Done Right

November 26, 2020

How to Create U.S. Electoral Cartograms

No comments

I don't remember how I came across the set of cartograms I'm going to show you how to create. Alas, I wanted to recreate this mesmerising set of cartograms that Noah Veltman created based on election maps from various media outlets.


Noah's page contains the vector files for each map. I saved them individually and prepped the data in Alteryx so that I could build the polygons in Tableau. Download the workflow here.


I needed to create two branches because some of the States are divided up into parts. For example, Maine in the NPR map has four blocks since Maine allocates each of its four electoral college votes separately. This required the same steps to be reproduced twice. For those States with multiple blocks, I had to split out each block, pivot them, then split those results, and pivot one more time.

Once I had the CSV, it was pretty easy to build in Tableau.

  1. X on the Columns
  2. Y on the Rows (and reverse the axis)
  3. Set both X and Y to AVG
  4. Change the mark type to Polygon
  5. Add the Path field to the Path shelf (this tells table how to connect the edges of the polygon)
  6. Add the State field to the Detail shelf

From there, it was some formatting for the colors, etc. This process, I would think, would work for any SVG (vector) file. This was a fun little project. I learned a lot!

No comments

Post a Comment