# An Introduction to Slopegraphs - Part 2

Tim Brock / Monday, June 8, 2015

In my previous post I looked at showing changes in time using slopegraphs. This was done with reference to changes in population for thirteen of the G20 nations between 1960 and 2013. However, slopegraphs can also be used to show differences between categorical variables. Sticking with the theme of demographics, and with those same thirteen countries, the slopegraph below - created using R (you could use Excel) - shows life expectancies for the year 2012. The horizontal dimension no longer portrays changes in time, but two distinct categories: male and female. The data comes from the World Heath Organization.

This, clearly, doesn't look great. In Part 1 I pointed out that one may have to adjust labels in order to prevent overlapping of text. In the example above all numbers are given to the nearest integer, so we have multiple instances of two or more labels that should go in exactly the same place. To overcome this we can use a vector-editing tool (with a pdf version of the above chart) and create lists of labels.

The example below has a similar problem to the one above. In this case we are comparing crude birth rates and death rates in 2013, using data from the World Bank website. Numbers are given to one decimal place and this chart suffers from both partial and completely overlapping labels.

We can give some labels a little nudge up or down (when values differ by 0.1) and list the others (when values are identical).

The big issue with both of the edited slopegraphs above is that, because we have multiple labels in the same vertical position, we have ambiguity working out which country name corresponds to which line. We can, of course, work things out by glancing from one side of the chart to the other but this does require some extra mental processing. In Part 1 I used color to help distinguish overlapping lines. Here we can use color to associate labels with their corresponding lines. In the case of the life expectancy chart we need four colors in order to unambiguously pair each label with a line; in the birth and death rate example, two is enough.

So are these multicolored slopegraphs useful? For all countries featured we see that the life expectancy for males is less than that of females. (I've arranged the color scheme according to how big this discrepancy is - green for four years, pink for five years, blue for six years and orange for more than six years.) If you read Part 1 you would have seen that the populations of Japan and Russia both changed in interesting ways between 1960 and 2013 and have not grown much recently. From the chart we see that the life expectancy of men in particular is low. By contrast, the life expectancy in Japan for men is one of the highest and for women is the highest. From the right-hand chart above we can see that Japan does have the lowest birth rate (the colours used in this case are just alternating and have no other meaning). It also has the third-highest death rate. It isn't that the Japanese are dying young, they just have an aging population (and little immigration).

The color examples above allow for a general visual exploration of the data. But if we really are just concerned with the details of one or two countries - like Russia and Japan - we can keep things grayscale and not have to worry about whether the charts will work in print or if readers with color-vision deficiencies will be able to distinguish labels. We can emphasize the countries of interest by making their labels bold and their lines black. We can deemphasize the other countries by using gray for their labels as well as lines.

Russian and Japan stand out as desired, yet we still have a background of other lines and labels to provide context. We might not be able to distinguish Australia from Italy without glancing from side to side but we can still read down the columns and compare the slopes of Russia and Japan to, collectively, everything else.

With reference countries relatively faint we can add a few more without worrying too much about clutter. Furthermore, the charts are useful coming from the other direction. Rather than highlighting countries of interest and looking to see if they're different, we can highlight countries that are different in some way. For example, below on the left we highlight only countries whose difference in life expectancy between men and women is greater than 7 (just Russia). On the right we highlight countries with a higher death rate than birth rate. In both cases we include (emphasized or deemphasized) all 19 of the G-20 nations.

To summarize, slopegraphs can be a simple (in terms of visual components) but effective form of data presentation. However, in some cases it can take a little extra thought and effort to make them clear and readable.

Want to build your desktop, mobile or web applications with high-performance controls? Download Ultimate Free trial now and see what it can do for you!