Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
This visualisation was published in an article in The Economist (2021) entitled Which is the strongest Olympic team of all time?. The newspaper is mostly read in English speaking Western nations and publishes news articles with topics ranging across current affairs, international business, politics, technology, and culture. The article was most likely targeting general news readers and the newspaper’s regular readership, as the Olympics is a mainstream and prominent topic when it comes about. The objective was to identify an advantage for Olympic host nations, the influence of politics on performance, and/or the strongest Olympic team of all time.
The visualisation had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
# install.packages("magrittr")
# install.packages("tidyverse")
# install.packages("readxl")
# load libraries
library(magrittr)
library(tidyverse)
library(readxl)
# load data
oly <- read_excel("medal_table.xlsx")
# calculate medal share by year
props <- oly %>%
group_by(Year) %>%
mutate(freq = (Total / sum(Total)) * 100) %>%
data.frame()
# filter for country with highest medal share by year...
first <- props %>%
group_by(Year) %>%
slice_max(order_by = freq, n = 1) %>%
summarise(freq1 = median(freq))
# ...then second highest...
second <- props %>%
group_by(Year) %>%
slice_max(order_by = freq, n = 3) %>%
summarise(freq2 = median(freq))
# ...and third highest...
third <- props %>%
group_by(Year) %>%
slice_max(order_by = freq, n = 5) %>%
summarise(freq3 = median(freq))
# filter for host country medal share by year
host_medals <- props %>%
filter(Host == TRUE)
# filter out unnecesssary columns
host_medals <- host_medals %>%
select(Year,Nation,freq)
# join all the tables
medals_freq <- host_medals %>%
left_join(first, by = "Year") %>%
left_join(second, by = "Year") %>%
left_join(third, by = "Year")
# create long form data
medals_freq2 <- medals_freq %>% gather(
`freq`,
`freq1`,
`freq2`,
`freq3`,
key = "type",
value = "freqs"
) %>%
data.frame()
# set type column as factor with labels
medals_freq2$type <- factor(
medals_freq2$type,
levels = c(
"freq",
"freq1",
"freq2",
"freq3"
),
labels = c(
"Host nation",
"Nation with most medals",
"Second most",
"Third most"
)
)
# join with wide form table (needed to create range line)
medals_freq2 <- medals_freq2 %>%
left_join(medals_freq, by = "Year")
# filter out unnecesssary columns
medals_freq2 <- medals_freq2 %>%
select(Year,type,freqs,freq,freq1,freq3)
# WWI and WWII annotions - decided not to use in final
annotation <- data.frame(
x = c(1916,1942),
y = c(30,30),
label = c("WWI", "WWII")
)
# instantiate ggplot object
p1 <- ggplot(
medals_freq2,
aes(y=freqs, x=Year, color=type, size=type)
) +
# show all x axis ticks
scale_x_continuous(
"Year",
labels = as.character(medals_freq2$Year),
breaks = medals_freq2$Year
) +
# add range lines layer
geom_linerange(
aes(ymin=freq1,ymax=freq3),
size = 1.5,
colour = "grey90"
) +
# add data points layer
geom_point() +
# comment-in below to see with annotation
# geom_text(
# data=annotation,
# aes(x=x, y=y, label=label),
# color="black",
# size=2.5 , angle=0
# ) +
# specify colours dor data points
scale_color_manual(values = c(
"blue",
"black",
"grey50",
"grey70"
)) +
# re-adding the Host nation data point so it overlaps the others
geom_point(
aes(y=freq),
size = 2.5,
shape = 21,
fill = "blue",
colour = "blue"
) +
# edit data point sizes
scale_size_manual(values = c(2.5,1,1,1,1)) +
# classic theme with no grid lines
theme_classic() +
# fix up titles
labs(
y = "",
title = "Home advantage?",
subtitle = "Share of medals won by Olympic host nation, %",
color = "",
size = ""
) +
# 1. adjust x ticks - neither hjust nor margin worked to fix the
# positioning of the ticks, so they are slightly unaligned
# unfortunately
# 2. add y axis grid
theme(
axis.text.x = element_text(angle = 90, size = 7),
panel.grid.major.y = element_line(linetype = 1)
)
Data Reference
The following plot fixes the main issues in the original.