Slopegraphs in Tableau

In Tufte’s The Visual Display of Quantitative Information, and recently on his blog, he discusses the use of slopegraphs to show change over time. They are highly effective because you have both the text (the reader would likely want to know the individual values), the sorting, and the slope which allows you to understand the magnitude of change and those countries that bucked the trend of increasing over the time period.

Creating them however is more of a challenge. While it would seem that with some creative label calculations combined with a line chart would suffice, in this data set (and many I would suspect) the line ends are too close together (see first tab below). In fact Tufte has manipulated the positioning of the line ends and labels manually to provide some spread on the axis. This, of course, provides a challenge if you want to automate the process in any way. I approached this by calculating the start and end positioning of each country using a table calculation (see tab 2), and using this to position the countries (tab 3). Of course, this loses the slope information and only shows the position change. To add the slope back in I use a calculation that combines both the index and original value to ensure that the lines cannot end too close to each other (tab 4). I then manually moved the labels to a better position to create the final slopegraph (tab 5).

Comments on the workbook: 1. Note that the label calculation is has the left() statements because of issues when you use extracts – 46.8 turns into 46.8000000001 or similar. 2. I spent ages trying to get this to work, but as soon as I put the label (country plus value) on the label shelf, it would alter the table calculation (I don’t know why as it’s a string). Making the label an attribute stopped that. 3. This method affects the slope of the lines to some degree. Another option would be shift the correct slopes up and down, thus making the vertical positioning slightly wrong (EDIT: This method now appears on sheet 5a. It turns out that this is really hard to get right – the order messes up, and you end up moving everything around – try changing the parameters yourself and getting the spacing and order correct. Looking back at the original, Tufte changes the slope as per my first method).


  1. Mike
    Jul 14, 2011

    Hi Alex,

    Thanks for putting this together…it’s another great demonstration of how Tableau can be used. There are two things, though, that I’m a little unclear on:

    1. Why did you use the math you did for the Value(Spaced) measure? It obviously gives you a good axis, but it isn’t clear why you chose the values you did. Was it just the result of repeated attempts until you got something you liked, or is there some logic behind the values you chose? I’d like to be able to explain this to my colleagues, and right now find myself unable to. :-)

    2. On tab 5, how did you get the labels to appear next to the line ends (left and right, respectively)? I replicated all of your formatting selections, but my labels still appear below each line end. Did you need to manually move each label, or is there another setting that I simply haven’t discovered yet?

    Looking forward to your response. I can definitely see a use for this with some of our visualizations.



  2. Mike
    Jul 14, 2011

    Just re-read your post…you already answered my second question. :-) The first one still stands, though.

    • Alex Kerin
      Jul 15, 2011

      Thanks for your comments Mike. I wish I could say (for point 1) that I did something more scientific than just try numbers…

  3. [...] special thanks to Alex Kerin over at the Data Driven Consulting blog for his excellent write up on working with Tableau for Slopegraphs. Was very helpful in getting mine created. Posted in [...]

Leave a Reply