Robert Kosara has an interesting post up on EagerEyes where he uses Tableau to visually highlight trends in states' presidential party preference. Two readers suggested that the states should not be arranged alphabetically, instead clustering them in some fashion that groups like-minded states.

A reasonable approximation would be to sort states according to the percent of time they voted for a given party. To break ties we can sort by the latest year that each state voted for that party. Here's the resulting image:


The sort order is based on party preference aggregated over time, which is difficult to perform in the view above since time itself is a dimension; we must first sort in the absence of time, and allow that sort order to persist as we evolve the visualization. To create the view above let's start with a simple view of party vs. state.

Next we define a calculated field 'CntPartyLastYear' that will aggregate the count of a state's party preference over time, along with the tie-breaking value of the most recent year a state voted for each party (converted to a fractional value).

  • CntPartyLastYear:  COUNT([Party]) + MAX([Year]) / 10000

Place this field on the "Text" shelf and create a table calculation for the percent of a state's total vote to see the split in party preference aggregated over time:

Finally select a column (I arbitrarily chose the Republican party) and sort.  This sort order will persist as we modify the visualization to create the final image.  Remove 'CntPartyLastYear' from the Text shelf.  Move 'Party' from the Columns shelf to the Color shelf, and place 'Year' (discrete, all values) on the Columns shelf.  Note that this final step now incorporates time without disrupting our sort based on aggregation over time.

If you'd like to experiment, here's the packaged workbook (TWBX). We offer a free trial that you can quickly download and install to play with the data analysis yourself.


My effort is here:

For sorting the States I used an exponentially-decaying weighting scheme. I gave each State 1 for a "D" vote in 2008, 0.8 for a "D" vote in 2004, 0.64 for a "D" vote in 2000, etc., back to 1980, breaking ties alphabetically by State abbreviations. I decided to stick with States by columns and time by rows, but put 2008 at the top out of personal preference. I also chose to have Party letters for two reasons. First, it avoids needing a key for third parties (P and SR), second if printed in grayscale it would still be legible (a precept dinned into me as a student).

I also experimented with making the "D" or "R" formatted differently (boldface, italics, etc.) whenever different from the previous election to emphasize when a State switched, but decided those looked too busy and anyhow the contrasts are reasonably obvious as it stands.