Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The objective of the original visualisation is to present the fluctuating US inflation rate, emphasising the relative magnitude of current inflation rates. The target audience of this visualisation is a layperson without technical economics knowledge, with the intent of showing that current levels of inflation are high by historical standards.
The visualisation chosen had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
library(ggplot2)
data <- read.csv('inflation_data.csv')
head(data)
## CPI.rate.p.a. Date
## 1 2.0 01/01/1914
## 2 1.0 01/02/1914
## 3 1.0 01/03/1914
## 4 0.0 01/04/1914
## 5 2.1 01/05/1914
## 6 1.0 01/06/1914
str(data)
## 'data.frame': 1299 obs. of 2 variables:
## $ CPI.rate.p.a.: num 2 1 1 0 2.1 1 1 3 2 1 ...
## $ Date : chr "01/01/1914" "01/02/1914" "01/03/1914" "01/04/1914" ...
data$date<- as.Date(data$Date, format = "%d/%m/%Y")
head(data)
## CPI.rate.p.a. Date date
## 1 2.0 01/01/1914 1914-01-01
## 2 1.0 01/02/1914 1914-02-01
## 3 1.0 01/03/1914 1914-03-01
## 4 0.0 01/04/1914 1914-04-01
## 5 2.1 01/05/1914 1914-05-01
## 6 1.0 01/06/1914 1914-06-01
p <- ggplot(data = data, aes(x = date, y = CPI.rate.p.a., colour = CPI.rate.p.a.))
p1<- p + geom_point() +
geom_line(aes(group = 1)) +
geom_smooth(se = FALSE, span = 0.4, colour = "black") +
scale_colour_gradient2(name = 'Inflation Rate (% p.a.)',
limits = c(-25, 25),
low = 'red', mid = "blue", high = 'red',
midpoint = 0,
guide = guide_colourbar(direction = "horizontal",
barheight = unit(2, units = "mm"),
barwidth = unit(40, units = "mm"),
draw.ulim = F,
title.hjust = 0.5,
label.hjust = 0.5,
title.position = "top")) +
labs(
title = "US Consumer Price Index Fluctuation",
subtitle = "Percent change in US CPI between Jan 1914 and Apr 2022",
x = "Date",
y = "Inflation Rate (% p.a.)",
caption = 'Source: U.S. Bureau of Labor Statistiscs'
)
p2 <- p1 +
theme(legend.position = "top") +
theme(legend.background = element_rect(fill = "#f5f5f2", colour = NA)) +
theme(panel.grid.minor = element_blank()) +
theme(plot.background = element_rect(fill = "#f5f5f2", color = NA)) +
theme(text = element_text(family = "Helvetica")) +
theme(axis.text.x = element_text(size = 12, color = "gray35")) +
theme(axis.text.y = element_text(size = 12, color = "gray35")) +
theme(plot.title = element_text(color = "gray10", size = 18)) +
theme(plot.subtitle = element_text(color = "gray40", size = 12)) +
theme(plot.caption = element_text(color = "gray40", size = 10)) +
theme(axis.title.x = element_text(hjust = 0, size = 14, color = "grey20")) +
theme(axis.title.y = element_text(vjust = 1, size = 14, color = "grey20")) +
theme(legend.text = element_text(size = 10, color = "grey40")) +
theme(legend.title = element_text(size = 10, color = "grey30"))
Data Reference
The following plot fixes the main issues in the original.