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

Original


Source:https://howmuch.net/articles/international-trade-as-a-share-of-state-GDP


Objective

  • This graph shows which states are most vulnerable to trade wars. The graph above is a circular bar chart, in which each blue bar represents the state’s total GDP ($Billions).

  • Added a color-coded red bar to show what percentage of a state’s economy depends on trade, owing to the state’s size.

The visualisation chosen had the following main issues:

  • Color Issues: The gradient color used for the Trade shares of GDP is somewhat confusing.Two colours are used which are quite contrasting. It is difficult to see the differences as we proceed towards the bottom spiral of GDP (Wyoming has a trade share of 5% whereas Vermont has a trade share of 20%).

  • The area of the graph has low accuracy for representing numeric values. The scale indicates trade shares of GDP range to make the chart more accurate. Due to the circular shape and the many sections in the scale, it’s still difficult to determine the different shares of state GDP.

  • Sorting: Circular bar graphs allow sorting through only one variable, GDP. One finds it difficult to compare the trade shares of GDP because they aren’t sorted.

Reference

Code

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

#Installing the packages
library(ggplot2)
library(magrittr)
library(tidyr)
library(magrittr)
library(readr)

#Importing the file
data<- read_csv("C:/Users/Admin/Downloads/Income.csv")
View(data)

#Renaming column names
colnames(data) [1] <- 'States' 
colnames(data) [2] <- 'GDP'
colnames(data) [3] <- 'Exports&Imports'
colnames(data) [4] <- 'TradeShares'

#The graph shows the States sorted according to their GDP
P1 <- ggplot(data, aes(reorder(States, GDP,width=1.5,position = position_dodge(width=2)), GDP, fill = GDP)) +geom_bar(stat = "identity", color = "white") +labs(x = "States- Ranked by GDP",
       y = "GDP, 2017",
       title = "State USA GDP 2017",
       fill= "GDP ")+coord_flip()+
  scale_fill_gradient(high = "#ed2311",low = "#dce320") +
  scale_y_continuous(labels=function(GDP) format(GDP, big.mark = ",", scientific = FALSE)) +
  geom_text(aes(label = GDP), position = position_dodge(width= 1), 
            size = 1.8,  vjust = 0.3,hjust=-0.10, color= 'black') +
  theme_classic()+
  theme(plot.title = element_text(color="black",hjust=0.5, size = 24, face = "bold"),
        text = element_text(size=6))

#The graph shows the states sorted according to Tradeshare percentage
P2 <- ggplot(data, aes(reorder(States, TradeShares,width=1.5,position = position_dodge(width=2)), TradeShares, fill = TradeShares )) +
  geom_bar(stat = "identity", color = "white") +
  labs(x = "States-Ranked by Trade Share",
       y = "Trade Shares of GDP in Percentage",
       title = "Trade Share of GDP of State-2017",
       fill= "TradeShare") +
  coord_flip() +
  scale_fill_gradient(high = "#ed2311",low = "#dce320") +
  geom_text(aes(label = TradeShares), position = position_dodge(width= 1), 
            size = 2.5,  vjust = 0.3,hjust=-0.10, color= 'black') +
  theme_classic()+
  theme(plot.title = element_text(hjust=0.5, size = 18, face = "bold"),
        text = element_text(size=6))

Data Reference

Reconstruction

The following plot fixes the main issues in the original.

P1

P2