Maps and Heatmaps: Political Trends

In trying to understand political trends in the U.S., I sometimes default to creating maps. They are beautiful visualizations of voting results. But sometimes maps provide a snapshot of one election or one period in time in a way that does not facilitate viewing trends over time.

Here is an example, looking at each state’s delegation in Congress after the 2018 midterms (limiting it to the Lower 48 for the moment):

The nice feature of this visual is that it is in a format we know (map) and clearly shows the red and blue sections of the country. But if I want to look at a trend over time, this won’t do it. Using ggplot’s amazing facet_wrap feature and with just a couple of changes to the chart parameters, we get this:

That’s great, now we can see trends over time. It gets harder to look at an individual state, though, especially in a dense part of the country like the mid-Atlantic states. What if we gave up our beloved maps and went to something that would actually provide more information?

Good data visualizations should provide the viewer with an immediate communication of the story in just a few seconds. But a great data visualization offers that plus an opportunity for the viewer to glean many more insights by spending a few more moments with it. Enter the heatmap containing the same information.

Here, a number of shifts jump out at us:

(1) 1994 midterms where the Newt Gingrich-led Republicans won the House

(2) 2010 midterms where Republicans again took control of the House

A number of other things become much more visible, as well:

(1) states divided 50/50 — it’s easy to identify which states those are (in white) and for how long they stayed split — in one glance

(2) states that were reliably one color and then became reliably another (so far), i.e. Vermont (red to blue) and Georgia (blue to red)

(3) the only states that have stayed one color throughout (Alaska, Kansas— red, and CA, MA, NY, OR, D.C. — blue)

In this case, the same data offers itself to much more interpretation when presented in a simple heatmap rather than a geographic map.

As an added bonus, we can easily show the specific percentage for each cell in the heatmap.

Not as pretty but now it’s a great reference table, as well.

Here is the R for the multi-year facet-wrapped maps and the heatmap in case you want to build on them.

All election data in this article from MIT Election Data and Science Lab with details here.

Finance professional passionate about technology and building scalable processes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store