Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.

Original


Visualizing the State of Government Debt Around the World (Update, 2021)
Source: howmuch.net Visualizations / Visualizing the State of Government Debt Around the World (Update, 2021) section.


Objective

The purpose of visualisation is to depict the impact of Covid-19 to the World economies. The article discusses about the change in Government Debt to GDP ratio in all countries due to the impacts of the Pandemic namely, higher spending to stimulate their economies, lockdowns and virus impacting tax revenue.

The audience of the article is general public with a purpose of informing general public of the severity of the economic impact on countries due to the pandemic.

The Visualisation is based on the data sourced from International Monetory Fund.

The visualisation chosen had the following three main issues:

  • It is a very complex visualisation makes it very hard to refer to: The visualisation is created as a spiral graph starting from the country lowest Debt Ratio in 2021 moving towards the center of the “cyclone” as the Debt Ratio increases. Showing of the shape of each country virtually provides no additional information except the visualisation becomes more tiring to the eye. Extracting any summaries or comparisons such as comparing different countries, impact on developed vs. under developed countries, location based (continent etc.) comparisons, impact on neighbours is virtually impossible.
  • Colour selection: The visualisation has 6 different colours. These selected colours are not good for colour blindness and hard to be distinguished even by the naked eye of a normal person. The range of the colour selection is not uniform either which can make referring the visual with reference to colour a bit tricky (unless there is a valid reason; which is not clear).
  • Data accuracy and Integrity of the visual: The article and the visual wants to analyse the impact of the pandemic on the economies (debt ratio specifically). But the visual provides the Debt Ratio snapshot of year 2021. That does not show the change from pre-pandemic to post-pandemic status. For example, even though Sudan is the highest in Debt Ratio, the change due to the pandemic is low. In fact, Sudan is one of the best performed countries in Africa during the Pandemic and even improved their Debt Ratio.

These issues are addressed and resolved in the code as follows:

  • Complexity: Visualisation is simplified with Dumbbell graph (ggplot version) by referring both pre-pandemic (2019) and post-pandemic (2021) debt ratio data as discussed in the article. Further, the graph is divided in to individual Continent in northern and southern hemisphere, Countries arranged according to the impact (increase / decrease in debt ratio) they experienced. This provides clarity and easy to compare Continents and Countries.
  • Colour selection: Colours are carefully selected based on ColourBrewer colour palettes (Set1) testing for Colour Blindness. Only the first two colours of the palette are selected for simplicity and arranged in reverse order to highlight reference year in Blue and end result in Red.
  • Data accuracy and Integrity of the visual: As the Article discusses about the impact of the Pandemic on the Economies, more importance is given to the “change” in Debt Ratio. The change in Debt ratio is calculated, shown with dumbbells connecting the two years and arranged in descending order in the graphs for each Continent. This shows the Countries who were worst impacted on the top of each graph and countries had lesser impact or performed better to the bottom of the graph. Even though this is a negative approach, it facilitates to illustrate the subject discussed in the article.

Reference

Code

The following code was used to fix the issues identified in the original.

# Calling the neccessary libraries:

library(ggplot2)
library(dplyr)
library(patchwork)
library(ggrepel)
library(stringr)
library(tidyr)
library(tinytex)
print(getwd())
## [1] "C:/Dassa/RMIT/MATH2404 - Data Vis & Com/Asses_2/assignment2template1950"
# Data Reading
# Read IMF Data on World Debt Ratio for Countries
imfdm1 <- read.csv('imf-dm-export-20230723.csv')

# Read list of countries by Continent and trim String type fields
continents <- read.csv('list-of-countries-by-continent-2023.csv')

# Data Cleansing
# Remove "no data" rows specific to Year 2021
imfdm <- imfdm1 %>% filter(X2021 != "no data")

# trim String type fields
imfdm$country <- str_trim(imfdm$country)
continents$country <- str_trim(continents$country)
continents$continent <- str_trim(continents$continent)

# Attach Continent to Countries and select only the necessary columns
# NOTE: Some of the names of the countries were to be manually updated to match the two data sources. 
countries <- imfdm %>% left_join(continents, c("country")) %>% select(country, continent, X2019, X2021)
countries <- countries %>% rename('2019' = X2019, '2021' = X2021)

# Convert the Debt Ratios to Double
countries$'2021' <- as.double(countries$'2021')
countries$'2019' <- as.double(countries$'2019')

# reduce length of the name of the Countries to improve visualisation real estate 
countries$country_pref <- str_sub(countries$country, end = 10)

# Create new column for pre-pandemic to post-pandemic Debt Ration difference
countries$DR_diff <- (countries$'2021' - countries$'2019')

# Pivot two years and create two columns "year" and "debt_ratio" 
countries <- pivot_longer(countries, cols = 3:4, names_to = "year", values_to = "debt_ratio")

# Split Countries to Continents
continent_splits <- split(countries, countries$continent)

# Function for creating a common ggplot layers for each Continent
ggp_function <- function(arg_continent) {
  data <- arg_continent
  contin <- first(data$continent)
  ggplot(data, aes(x = debt_ratio, y = reorder(country_pref, DR_diff))) +
    geom_line() +
    geom_point(aes(color = year), size = 1.5) +
    scale_color_brewer(palette = "Set1", direction = -1) + 
    xlim(c(0, 260)) +  
    labs(subtitle=contin, y="Country", x="Debt Ratio (%)") +
    theme(axis.text=element_text(size= 5),
        axis.title=element_text(size= 8), 
        plot.subtitle = element_text(size = 10,face="bold"))
}

# Separate Continents  
paf <- ggp_function(continent_splits$Africa)
pas <- ggp_function(continent_splits$Asia)
peu <- ggp_function(continent_splits$Europe)
poc <- ggp_function(continent_splits$Oceania)
pna <- ggp_function(continent_splits$'North America')
psa <- ggp_function(continent_splits$'South America')

Data Reference

Reconstruction NHemisphere

The following plot fixes the main issues in the original.

Reconstruction SHemisphere

The following plot fixes the main issues in the original.