I recreated xkcd's Global Warming Viz in Tableau and this is what I learned

I spent some time trying to recreate the 2016 Kantar Information is Beautiful Gold Data Visualization winning entry on global warming in Tableau.  It was an interesting exercise and I wanted to share how I did it and some key insights from this process. 

Here is a screenshot of the original visualization by Randall Munroe, titled "A timeline of Earth's Average Temperature"


Here is a screenshot of my Tableau replication.  To get the full effect, you have to download and install the xkcd font first.


Last month I wrote a blog describing how to creating your own font and have been obsessed with typography since.  After seeing Adam Crahen's Tableau community handwriting viz, I happened to walk by a copy of Randall Munroe's Things Explainer and noticed the typography.  After a quick internet search, I found the official xkcd font: it is awesome.  With the font installed I was ready to build something and the Global warming viz immediately came to mind.   

What I learned:

From a style perspective, my key takeaways were:
1) Annotations are really important (and I need to use them more)
This is a really long visualization which I imagine was done intentionally to emphasize the length of the timescale.  How do you make the reader keep scrolling?  Keep them interested in the story and want to keep going.  There is an annotation or drawing at least once every 500 years.  Not only were they interesting and funny, they also provided rich context to help tell the story.  
2) and so is humor
Global warming is a serious topic, but in typical xkcd fashion, there were multiple jokes peppered in the comic to keep the reader engaged.  While recreating every detail, I picked up on several new jokes I hadn't noticed in my prior 100+ views

From a technical perspective, here are some techniques I used that might be new to you

1) Data creation
Tools used: Google Sheets

After I decided to work on the project, I needed to generate the data set.  I figured I only needed to record the year and the rough temperature using the scale in the original.  I decided it would look best of I tried to record a temperature every 100 years (mostly to keep the line movement smooth).  After I initially plotted the data, I had an issue with the date sorting (BCE vs. CE).  I ultimately created an additional sort column that used a negative number for BCE.  Here is my final data set.

2) Custom colors
Tools used: Notepad & Instant Eyedropper

The first thing I notice about the original viz is the beautiful color scale.  In order to get the banding to work in Tableau, I had to create a custom color palette.  First step is to get the colors.  To do this, I used a tool called lnstant eyedropper.  It lives in your toolbar and you just click the icon and drag over any color to get the hex code. 

After saving the color codes, I created a palette and added the code below to my preference.tps file (more details can be found here about modifying your preference file). Note: only "ordered-sequential" palettes are available in reference bands.

<color-palette name="XKCD" type="ordered-sequential" >

3) Customized Reference Band
Tools used - Tableau

The original has four shades of blue and red on each side of the zero line (with an off white color on both sides of the 0 line).  First, I created a calculation, WIDTH, that was set to the number 5, one for each color on each side of the zero line.  Next, I add a distribution band from the analytics pane.  The distribution band provides 4 options for banding: Percentages, Percentiles, Quantiles and Standard Deviations.  I chose percentage and used my calculated field, WIDITH, as the value.  I entered the percentages as -100,-80,-60,-40,-20,20,40,60,80,100 to line up the bands accordingly.  

When formatting the bands, I chose the xkcd color palette from the dropdown

4) Exceeding the 4000px limit
Tools used: Notepad

After plotting the data, I quickly realized the length of the viz was an issue.  I checked the original comic and saw it was 14957px long while Tableau dashboards have a maximum length of 4000px.  I mentioned this challenge to Pooja and she pointed me to a Think Data Thursday session she had with Shawn Wallwork, who spoke about extending the maximum length via an XML hack.  

1) opened your twb file with notepad and search for "maxheight" to find your dashboard settings
2) change the value from 4000 to 9999 for both min and max height 

Shawn also noted that this hack may cause problems on some hardware. 

5) Multiple Paths
Tools used - Google Sheets

I almost never use the path shelf but the three future scenarios provided the perfect use case.  I used this reference doc to build my data set:

6) Image Manipulation
Tools used - Powerpoint

A huge component of the look and feel of this viz are the classic xkcd stick figure drawings.  Adding them to Tableau was not a direct copy/paste operation since the height of my viz differed from the original, which caused some background color misalignment.  I used Powerpoint to strip away the background colors of screenshots and then made them transparent.  It wasn't perfect but good enough.  Here is a case where I lost some of the data while removing the background colors:

For more image manipulation in Powerpoint reading - I recommend Josh Tapley's blog 

Overall, this was a fun exercise.  I learned a few new tricks, have a new favorite font and have a much greater appreciation for xkcd.