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

Original


Source: https://twitter.com/stlouisfed/status/1617266021810724866?cxt=HHwWhICzlZq41_EsAAAA.


Objective

The graph appears to have been created to convey the message that China’s military spending is increasing over time and that China’s military spending is higher than that of the United States. The target audience for the graph could be the general public or policymakers who are concerned about military spending and potential threats to national security.

There are three main issues with the graph. The first issue is overplotting, which occurs when multiple lines cross at the same points, making it difficult to distinguish between the different lines and track changes in the data over time. An example of this is with the data points from India in the pink dotted line. Due to overplotting, it is difficult to see the placement of the line, and this issue makes it hard to follow the change in the data of specific countries over time. This is clearly illustrated between 1995 and 1997.

The second issue with the graph is deception, which arises from the use of a dual y-axis. The graph shows different countries’ military spending on the left y-axis, while the right y-axis is used only for the United States. This creates a skewed perception of the relative spending values, and it may mislead the viewer into thinking that China’s military spending is higher than the United States’. This issue could affect the viewer’s decision-making.

The third issue with the graph is the use of color. The colors of China, Russia, the U.K, and Saudi Arabia are similar, and this could create issues for people with red-green color blindness in distinguishing between the different countries. This issue can be seen in the “Colour Blindness Test of Plot” tab, where it becomes more difficult for people with red-green color blindness to tell the difference between the countries. An example of this is with the lines of Saudi Arabia and Russia. The type of line helps, but the color of Saudi Arabia and Russia are almost exactly the same. You can also just barely see the line for india. This issue can make it more difficult for people with color blindness to interpret the graph accurately.

Overall, the issues identified in the graph could affect the viewer’s understanding of the data and lead to inaccurate interpretations.

Reference

Code

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

library(ggplot2)
library(readxl)
library(reshape2)

exceldata = read_xlsx("/Users/nicklawler/Documents/Data Visualisation/Military_Expenditure_final.xlsx")                                                                            
militaryExpediture = data.frame(exceldata)

library("dplyr")

#Rename column name for readability
militaryExpediture <- militaryExpediture %>% 
  rename("Country" = "...1")


# Reshape data frame to long format
militaryExpediture_melt <- melt(militaryExpediture [,c('Country',"X1992...1996", 
                                                       "X1997...2001", "X2002...2006", 
                                                       "X2007...2011", "X2012...2016",
                                                       "X2017...2021")],id.vars = 1)

# rename the column to Year_Range
colnames(militaryExpediture_melt)[2] <- 'Year_Range'

# Change the scipen option so that the scientific scale is not used and more readable
options(scipen = 999)

p <- ggplot(militaryExpediture_melt,aes(x = Country, y = value)) + 
  geom_bar(aes(fill = Year_Range),  # Colour each bar based on Year_Range
           stat = "identity", 
           position = "dodge") +  # specify that we want to dodge the bars so they do not overlap
  ylim(0, 850) +
  labs(y= "Military Expenditure in U.S$ (billions)", x = "Country", 
      title='Military Expenditure Among Nations with the Highest Expenditures',
      subtitle='The colour scale represents 5 year intervals from 1992 - 2021',
      caption = 'Source: https://milex.sipri.org/sipri') +
  scale_fill_brewer(name = 'Year Range', labels = c("1992 - 1996", 
                                                   "1997 - 2001", 
                                                   "2002 - 2006", 
                                                   "2007 - 2011", 
                                                   "2012 - 2016", 
                                                   "2017 - 2021")) 

p1 <- p +  
  theme_dark() + 
  # adjust gridlines so they are more subtle
  theme(panel.grid.major = element_line(linewidth = 0.06, linetype = 'solid', colour = "white"), 
        panel.grid.minor = element_line(linewidth = 0.06, linetype = 'solid', colour = "white")) +
  # adjust the x-axis expansion to make more room
  scale_x_discrete(expand = expansion(add=0.55)) 

Data Reference

Reconstruction

The following plot fixes the main issues in the original.