How To: FiveThirtyEight Electoral College Cartograms in Tableau


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.

How To: Add Vertical Lines to Slope Graphs With Multiple Measures


Andy Kriebel recently posted a great tutorial on adding vertical lines to a slope graph using reference lines.  This works great for slope graphs where you are comparing the same measure across dimensions, but what if you want to compare two measures across a dimension?

Using the Superstore data set, let's say we wanted to look at the percentage of Sales compared to the percentage of Profit across Categories.  First let's build our slope chart.

1. Drag the Sales pill to Rows and Category to the color.


2. Drag the Profit pill to the left side of the stacked bar so that you see the side by side bars.


3. Change the mark to line and create a percent of total table calculation on both measures.


4. Drag Measure Values to the label, format the percentages, and order the Measure Value pills so that Sales is on top.


Now we can see how Percent of Sales relates to Percent of Profit by category.  Now we want to be able to add those nice vertical lines to add structure and alignment to the visualization.

Since we are using different measures, we won't be able to use the calculations Andy used to create reference lines.  However, we can create reference lines using bar charts.

5. Create a calculated field with the value of 1.

6. Drag the calculated field to the Rows.  Move Measure Values to the detail and turn off the labels. Remove Category from the Color.



7. Create a dual axis.


8. Change the mark to a Bar, reduce the transparency, change the color, and turn off borders.


9. Reduce the size of the bars.


10. Edit the axis of the calculated field and set it to a fixed axis where the number is low enough for the vertical lines to extend to the top of the view.  Also, edit the axis of the Measure Values so that it is fixed from 0 to 1.




11. Switch the position of the pills on the rows shelf so that the vertical lines move to the back.  Hide the headers and clean up the chart.



That's it!  Now you have a slope graph comparing two measures with vertical lines.

Feel free to download the workbook and comment with any questions.

My Journey to Zen

Last week I learned that I was selected as a Tableau Zen Master.  I am extremely excited and humbled to join such an exceptional group of Tableau talent.  As I reflect on my journey, I wanted to share a few tips that helped me and will hopefully inspire others.

Attend the Tableau Conference
If you have the means, I cannot recommend this enough.  When I first attended TC14, I had only been using Tableau for a few months.  Most of my work was centered around higher education, so I primarily attended sessions that were related in nature.  Eventually, I grew tired of the same topics, so I branched out and attended sessions that sounded interesting.  I noticed a session called Porn, Pokemon, and Pop Culture put on by Jewel LoreeAndy Kriebel, and Peter Gilks.  I figured with a title like that it must be interesting.  To my surprise, my mind was completely blown.  I had no idea people were visualizing and analyzing data as a hobby and then blogging about it.  I was completely hooked, and this started my foray into Tableau Public work.

Find a Mentor
My Tableau mentor is Andy Kriebel.  I first met Andy at TC14.  Despite being extremely busy with all of his Zen Master and community obligations at the conference, Andy took the time to meet me for breakfast, talk to me about the Tableau community, and inspired me to start participating.  That has always meant a lot to me, and it shows just how dedicated he is to contributing to the Tableau community.  Andy and I also both happened to attend Clemson University, so we've always had that connection, but he's always been there for me.  When I came home from TC14 and created my first Tableau Public visualization, it was Andy who encouraged me to post it.

Put Yourself Out There
A common theme I hear from people who are apprehensive about participating in the Tableau community is that they are afraid people won't like their work.  I understand the fear of having your work judged and critiqued, but there are a few things to keep in mind:

You're in good company.  The Tableau community is full of people that have gone through the same thing before.  We all know how hard it is to put work out for the world to see, and most members of the community offer constructive criticism.
It will never be perfect.  I am a perfectionist, so I know how it is to get caught up in this line of thinking.  Some people have told me that they didn't publish their work to Tableau Public because it wasn't perfect.  There is no such thing as perfect when it comes to data visualization.
Embrace the (constructive) criticism.  This is probably difficult for a lot of people as well, but it is a necessary part of a feedback loop that will ultimately result in becoming a better practitioner of data visualization.  I have had over 700k views on my Tableau Public work.  With all of those views comes a lot of criticism.  I like to post a lot of my work on Reddit, and I use that as a place to get honest criticism on my work.

Relish the Learning Opportunities
This is a huge one for me personally.  Last year I competed in the Iron Viz competition, and I was not happy with my performance.  One thing that I learned about myself from that experience is that I was not very good at data storytelling.  I come from a very technical background, even though I have an MBA, so I have always been more adept at software development, data integration, and advanced analytics.  One thing I really wanted to improve on over the last year was my data storytelling abilities.  This led to working with Nelson Davis and Alex Duke to create the Reviz Project.  This is something I am very proud of, and I feel like my data storytelling abilities have improved immensely over the last year.

Innovate on the Work of Others
The best thing about the Tableau Community is that so many are willing to share the fruits of their labor.  For example, last year Brittany Fong shared a post on how to make tile maps in Tableau.  I was immediately fascinated with this technique, and I wanted to see if I could do the same thing for creating hex tile maps.  I figured out how to lay out the coordinates, and I wrote a tutorial on how to create hex maps in Tableau.  This has consistently been my most viewed blog post.

Like many others have said before, becoming a Zen Master should not be a goal.  There is no checklist of things you can do to become a Zen.  However, my goal is to encourage others to participate in and get the most out of the Tableau community.  I hope these tips help you engage with and learn from the community, and who knows, maybe you'll be the next Tableau Zen Master.

Thanks,
Matt







Finding the Small Stories in NCAA Football Data



Like many others in the field of data visualization and analytics, my love of data began with sports.  As a kid, I memorized the statistics of my favorite players and teams.  My friends thought that I was weird for knowing who Yinka Dare was, but I knew every player in the NBA at that point.  I could, and still can, recite from memory the starting lineup of every 1990s NBA Championship team.  This love of sports data has persisted through the years, and with the emergence of data visualization tools such as Tableau, I am now able to explore data in ways I never imagined as a kid.

I really enjoy analyzing sports statistics, but I also find that there are many stories to tell when looking at sports from the macro level.  Previously, I have visualized the history of the NFL in a similar manner, but I have always wanted to do the same for NCAA Football.  This was a bit more ambitious project since there are 128 Division 1 teams, but I was able to get the data from Sports-Reference.  Once I pulled down all the .csv files, I was able to use some Alteryx magic to build the complete data set.

Once I had the data, I wanted to build a small multiple view that would allow for the entire history of NCAA Football to be seen in one visual.



This view easily allows the user to see winning seasons, losing seasons, and championships.  Hovering on the team name or bars gives more details about the team or the individual season.

It is fairly easy to see how teams like Alabama in the SEC have dominated over the last few years.

However, there are several stories that can be found when looking at the patterns in the histories of teams.  For many sports analysts, Bill Snyder at Kansas State is considered one of the best coaches ever despite never winning a championship.  When we look at the data, it becomes apparent why he should be considered among the best.  Kansas State was perennially a losing team before Snyder took over.  With Snyder at the helm the team became a Top 10 team.  However, once Snyder retired, the team regressed back to their losing ways.  Snyder was coaxed out of retirement, and the team immediately returned to winning.



Most College Football fans are familiar with SMU’s scandal known as “Ponygate” in which the program was found guilty of paying players.  SMU was dealt the “Death Penalty” by the NCAA which caused the program to have to cancel the 1987 season.  SMU also cancelled the 1988 season as it would have been impossible to field a viable team.  The penalty left SMU in shambles as the program has had only four winning seasons since 1986.




These are just a few of the potential stories within the history of NCAA Football.  Download the workbook and tell the story of your favorite team.  I can’t wait to see what other stories unfold.