Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The objective of the original data visualisation is to highlight the size of military spending and armed force personnel by country. This visualisation is posted on the website howmuch.net, which states its objective as to use data visualisation to make understanding money easy. This website states its intended audience as people in the United Stated. Specifically, this visualisation aims to “To see the effects of military spending on the world’s economy”, and claims to let “us see total military spending around the world as well as the relationship between military expenses and armed forces personnel”.
However, there are several features of this visualisation which make these intended aims difficult to assess, and many of the observations stated in the accompanying article simply cannot be inferred from the visualisation. Outlined below are three major issues with this visualisation.
The visualisation chosen had the following three main issues:
An area scale has been used to show the size of military spending for each country, however the scale is both irregular and logarithmic. Area is already a difficult scale to interpret. Combining it with a logarithmic scale makes it even more difficult. In addition, the largest bubble size shown in the legend is $500 billion, which would need to be $1 trillion in order to be consistent with the remainder of the scale.
With the stated aim of illustrating the relationship between military expenses and armed forces personnel, it is almost impossible to infer any kind of relationship between defence spending and miltary size, which is one of the stated objectives of the visualisation. Mapping a continuous variable to an irregular, discrete colour scale makes interpretation difficult.
The stated aim of the visualisation is to aid the interpretation of military spending and military sizes for people living in the United States, however, the figure shows data for every country for which there is a data in the set. The inclusion of numerous, small nations, many of which would be unfamiliar to many people, leads to visual bombardment. While the countries are grouped by region, and mostly within a pattern related to military budget (except for Oceania), the figure can be difficult to navigate. Searching for a single country becomes time consuming without already knowing it relative size. In addition, the inclusion of all these countries takes up space which might have been better used on a more realistic size scale. It may be more prudent to only include the US’s neighbours, strategic rivals and major defence spenders within each region.
Reference
The following code was used to fix the issues identified in the original. The figure itself needed to be reimagined in order to better support the stated aims of the data. A Dorling cartogram was used to represent Military expenditure throughout the world, with the number of countries labelled reduced to the globally, or regionally largest military spenders in their region. Interactivity was added using the plotly package such that hovering over a bubble will allow for actual values to be obtained should the reader be interested in a specific country. Military expenditures (2018) has been mapped to the bubble size aesthetic in order, with the logarithmic scale removed to facilitate reading of the figure.
Two additional plots were used to highlight the largest and best (top 20) equipped military forces in the world. This allows for some comparisons between the audience (US residents) and other nations close of these metrics.
library(ggplot2)
library(readxl)
library(dplyr)
library(magrittr)
library(cartogram)
library(maptools)
library(cartogram)
library(rgdal)
data(wrld_simpl)
library(sf)
library(plotly)
setwd("~/University (Local)/Data Visualisation/Assignment 2")
#Get the data
dat1 = read_excel("World_military_data1.xlsx") %>% select(3,4,16)
dat2 = read_excel("world_military_data2.xlsx") %>% select(3,4,15)
names(dat1) = c("Country", "Code", "Budget_2018")
names(dat2) = c("Country", "Code", "Personnel_2017")
#Get the gegions from the wlrd_simp data set
regions = data.frame(Code = wrld_simpl$ISO3, Region = wrld_simpl$REGION, sub = wrld_simpl$SUBREGION)
#Join the data sets (with region data)
dat <- inner_join(dat1, dat2) %>% inner_join(regions)
dat$Budget_2018 %<>% as.numeric()
dat$Personnel_2017 %<>% as.numeric()
#Add ranks to the list
# Biggest Militaries
dat %<>% mutate(budget_rank = rank(-1*Budget_2018), personnel_rank = rank(-1*Personnel_2017))
# Add equipment variable to the list (with ranks)
dat %<>% mutate(Equip = Budget_2018/Personnel_2017) %>%
mutate(Equip = ifelse(is.infinite(Equip), NA, Equip)) %>%
mutate(Equip_rank = rank(-1*Equip))
# Convert to region to factor
dat$Region %<>% factor(levels = c(2,9,19,142,150), labels = c("Africa", "Oceania", "Americas", "Asia", "Europe"))
#Fix up some long names
dat$Country[dat$Code=="IRN"] <- "Iran"
dat$Country[dat$Code == "KOR"] <- "South Korea"
dat$Country[dat$Code == "PRK"] <- "North Korea"
dat$Country[dat$Code == "EGY"] <- "Egypt"
dat$Country[dat$Code == "PHL"] <- "Philippines"
dat$Country[dat$Code == "RUS"] <- "Russia"
# Merge world data with country names and variables
wrld <- wrld_simpl
tmp = merge(wrld, dat[,], by.x = "ISO3", by.y = "Code")
#Remove countries with no listed budget
tmp <- tmp[!is.na(tmp$Budget_2018),]
#Generate the dorling cartogram geometry
wrld_sf_carto <- cartogram_dorling(st_as_sf(tmp), "Budget_2018", k = 15, m = 1)
wrld_sf_carto$REGION %<>%
factor(levels = c(2,9,19,142,150), labels = c("Africa", "Oceania", "Americas", "Asia", "Europe"))
# Create the dorling cartogram with ggplot2
#Generate a text field for tooltip information when mapped to ggplotly
p1 <- wrld_sf_carto %>%
ggplot(aes(text =
sprintf("Country: %s \n Budget: $%.2f Billion \n Armed Forces: %i \n Budget per armed personnel: $%.0f thousands",
Country, Budget_2018/1e9, Personnel_2017, Equip/1e3))) +
geom_sf(aes(fill = REGION, colour = REGION))
#Generate a list of labels
subset_world = wrld_sf_carto[wrld_sf_carto$budget_rank < 21 |
wrld_sf_carto$ISO3 %in%
c("MEX", "NZL", "SGP", "ZAF", "ARG", "COL", "PHL", "SWE", "DZA"),]
subset_world = subset_world[subset_world$Country != "Pakistan",]
subset_world %<>% mutate(label = sprintf("%s \n %.2f", Country, Budget_2018/1e9))
p1 <- p1 + geom_sf_text(data = subset_world, aes(label = label), size = 3) +
theme(panel.grid.major = element_line(color = "white"),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
panel.background = element_blank(),
axis.ticks = element_line(color = "white"),
legend.position = "none") +
labs(x = "", y = "", title = "Military Expendature 2018 (Billions $USD)")
# Convert to plotyly to provide tooltip information
p1 <- ggplotly(p1, width = 1200, height = 1200/2.2, tooltip = "text")
p1 %<>% style(hoveron = 'points+fills')
p.personnel <-
dat %>% subset(personnel_rank < 21) %>%
mutate(Country = factor(Country, levels = Country[order(personnel_rank)], ordered = TRUE)) %>%
ggplot(aes(x = Country, y = Personnel_2017/1e3, fill = Region,
text = sprintf("%.i", Personnel_2017))) + geom_bar(stat = "identity") +
theme_minimal() +
theme(axis.text.x = element_text(angle=45, hjust = 1)) +
labs(title = "Biggest Forces - Size of Armed Forces (,000s)",
x = "", y = "") +
geom_text(aes(label=round(Personnel_2017/1e3,0)), vjust = -0.5,size = 3) +
theme(panel.grid.major = element_line(colour = "white"), legend.position = "none") +
scale_fill_discrete(drop = FALSE)
p.equipped <-
dat %>% subset(Equip_rank < 21) %>%
mutate(Country = factor(Country, levels = Country[order(Equip_rank)], ordered = TRUE)) %>%
ggplot(aes(x = Country, y = Equip/1e3, fill = Region,
text = sprintf("$%.f", Equip))) +
geom_bar(stat="identity") + theme_minimal() +
theme(axis.text.x = element_text(angle=45, hjust = 1)) +
labs(title = "Best Equipped Militaries - Expenditure per Military Personnel ($,000s)",
x = "", y = "") +
geom_text(aes(label=round(Equip/1e3)), vjust = -0.5,size = 3) +
theme(panel.grid.major = element_line(colour = "white"), legend.position = "none") +
scale_fill_discrete(drop = FALSE)
p.personnel %<>% ggplotly(width = 1200, height = 1500/2.2/2, tooltip = "text")
p.equipped %<>% ggplotly(width = 1200, height = 1500/2.2/2, tooltip = "text")
The following plot fixes the main issues in the original.
Data Reference
World Bank. “Military expenditure (current USD)”, World Development Indicators, The World Bank Group, https://data.worldbank.org/indicator/MS.MIL.XPND.CD?end=2018&start=1960&view=chart, Accessed 23/9/19
World Bank. “Armed forces personnel, total”, World Development Indicators, The World Bank Group, https://data.worldbank.org/indicator/MS.MIL.TOTL.P1?end=2018&start=1960&view=chart, Accessed 23/9/19