I was inspired to make this post after seeing this article by HowMuch.net which tries to show how 'sustainable' each country's debt is by measuring their debt-to-GDP ratio and providing contextual information about the GDP growth rate.
There are some great things about this visualisation. I like that the countries are position in their relative places on the globe, and the colour scale for GDP Growth Rate is sensible. What I find difficult to understand is how the size of each country has being scaled to the unsustainability of their debt. Sure, we can all see that Russia is much smaller than it would be on a normal globe, and Japan is far bigger, but how has the size of Iceland or Poland been changed relative to the original sizes?
I thought I could improve the readability of this chart by doing away with some of the fancier choropleth stuff, and instead focussing on creating a simple chart which displays this information intuitively.
In this tutorial we'll learn how to scrape data from a Wikipedia page, use Pandas for a bit of data manipulation, use the
colorlover module to create an ordinal colour palette for the visualisation, as well as designing three different visualisations with Plotly.
I'll try to take you through my thought processes in creating these visualisations; I created two charts before settling on the final version, and hopefully it will be helpful to you to understand the decisions I made.
There's loads to do here. I'm going to crack on.
I'll be using Pandas and Numpy to manipulate the data, Plotly for visualisation, and colorlover to choose a colour palette. HTML from IPython.display will let us look at the colour scales generated by colorlover.
import pandas as pd from pandas import DataFrame import numpy as np import plotly.offline as pyo import plotly.plotly as py from plotly.graph_objs import * import plotly import colorlover as cl from IPython.display import HTML plotly.offline.init_notebook_mode()