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

Original


Source: howmuch.net (2015), Visualizing Nominal GDP Around the World, by Raul Amoros


Objective

The original data visualization in the form of an uncommon Voronoi diagram aimed to present the relative size of each countries’ economy in terms of nominal GDP, allowing for the comparison of the scale of their total nominal GDP and to see how much each economic sector contributes to that statistic and how they differ compared to other countries.

Such visualization is made to be accessible towards the general public who may be interested in economics and becoming better informed about these financial statistics.

The visualisation chosen had the following three main issues:

  • It is difficult to discern and compare proportions of economic sector contribution towards the total GDP for smaller countries due to the significantly lesser footprint on the visualization.
  • The positioning of countries and economic sector proportions are not consistently placed on a shared axis, making a direct comparison or constructing a narrative difficult.
  • Because of the abstract use of area to represent the countries within the visualization footprint, the positioning of country labels and percentages are quite inconsistent with reduced readability.

Reference

Code

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

library(ggplot2)
library(readr)
library(tidyr)
library(dplyr)
library(scales)
options(scipen=999) 
# helps to disable scientific notation on large values in the visualization

# PREPROCESSING
data <- read_csv("WB data.csv") 

country_order <- data[data$`Economic Sector` == 'Gross Domestic Product (GDP)', ] %>% arrange(`GDP`)
country_order <- country_order$`Country Name`
# creating an order of countries based on their total GDP for 2015

data <- data %>% arrange(factor(data$`Country Name`, levels = country_order))
# applying the order of country GDP onto the original data frame
data$Psec <- as.numeric(data$Psec)
# transforming the Psec variable to a numeric one
data$Continent <- factor(data$Continent)
# creates factors of the continents to apply the respective color mapping in the plot

d <- data[data$`Economic Sector` != 'Agriculture', ]
# the data size for the data set to be used in the geom_segment clause of the plot requires a matching length to that of the original geom_col so any one of the economic sectors can be excluded as the total GDP is the one which matters to connect y = 0 to the y value of the point

#PLOTTING
reference_lines <- data.frame(GDP = c(0, 5000000000000, 10000000000000, 15000000000000, 20000000000000))
# creating a data frame of GDP values to plot a reference line along in the plot to help gauge scales on  the visualization
continent_colors <- c("Africa" = "#Baa65d",
                      "Asia" = "#FB9A80", 
                      "Europe" = "#5d8eba", 
                      "North America" = "#4acbc2",
                      "Oceania" = "#69906c",
                      "South America" = "#Ba5d5f")
# creating a color map for the continents that the country belongs to in order to classify them and make them distinct. More subtle colors of darker tones were decided on as their separation of alpha values would be more noticable.

sector_alpha <- c("Agricultural" = 1.0,
                  "Industrial" = 0.75,
                  "Manufacturing" = 0.5,
                  "Service" = 0.35)
# creating an alpha map for the economic sectors so within the continent color mapping, alpha values will differentiate these factors among the stacked bars


p <- ggplot(data = data[data$`Economic Sector` != 'Gross Domestic Product (GDP)', ], aes(x = factor(`Country Name`, levels = unique(`Country Name`)), y = `Psec`, fill = `Economic Sector`)) +
geom_hline(data = reference_lines, aes(yintercept = GDP), color = 'gray') +
geom_col(aes(fill = Continent, alpha = `Economic Sector`)) +
geom_point(data = data[data$`Economic Sector` == 'Gross Domestic Product (GDP)', ], aes(x = factor(`Country Name`, levels = unique(`Country Name`)), y = `GDP`, fill = 'black')) +
geom_segment(aes(y = d$`GDP`, xend = d$`Country Name`, yend = 0)) +
coord_flip() +
labs(fill = "Continent", 
     title = "Nominal GDP Across the Globe in 2015",
     subtitle = "The GDP per country and proportion of contribution from each major economic sector",
     caption = "World Bank (2023), World Development Indicators",
     x = "Country",
     y = "Gross Domestic Product (Trillion US$)") + theme(
  panel.background = element_rect(fill = "white")
  ) +
scale_fill_manual(values = continent_colors, limits = c('Africa', 'Asia', 'Europe', 'North America', 'Oceania', 'South America')) +
scale_alpha_manual(values = sector_alpha, limits = c('Agricultural', 'Industrial', 'Manufacturing', 'Service')) +
scale_y_continuous(labels = function(x) paste0(round(x / 1e12, 1), "T"))
# creating a horizontal stacked bar plot acting as a background, to better represent the proportion of GDP contribution based on economic sectors used in the original visualization as for smaller countries, such breakdown would not be easily discernible.
# layered on top of the bar plot is a simple geom_point with the countries total GDP that determines their order with an assisting geom_segment to provide additional emphasis on the point and aid comparison between countries.

Data Reference

Reconstruction

The following plot fixes the main issues in the original.