Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The objective of this visualisation is to show the ranked results of countries competing at the Beijing Winter Olympics, 2022.
The target audience would be a very large and diverse group of the worlds population, primarily the citizens of those countries that have athletes competing in the Olympic Games, and more broadly, anyone with an interest in the Olympic Games event.
The visualisation chosen has the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
library(ggplot2)
library(tidyr)
library(dplyr)
#import the dataset
medals_in <- read.csv("medals_total.csv")
#pivot long to split the medal tally for each medal type
medals_data <- medals_in %>%
pivot_longer(cols=Gold:Bronze, names_to = "medal_type", values_to = "count" )
#set the order of medal type
medals_data$medal_type <- factor(medals_data$medal_type, levels=c("Gold", "Silver", "Bronze"))
#reorder by total medal count
medals_data$Country <- reorder(medals_data$Country, medals_data$Order.by.Total, FUN = sum)
p2 <- ggplot(data = medals_data, aes(x = Country, y = count, fill=medal_type)) +
geom_bar(stat = "identity", width=0.7, position = position_dodge()) +
theme_classic() +
labs(title="Beijing Winter Olympics 2022", subtitle="Medal Tally by Country", x="Country", y="Medal Count", fill="Medal Type") +
scale_fill_manual(values=c("#ebc700", "#a8a8a8", "#CD7F32")) +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=0.95), panel.grid.major.y = element_line(color = "grey", size=0.5, linetype=2), plot.title=element_text(hjust=0.5), plot.subtitle=element_text(hjust=0.5))
Data Reference
The following plot fixes the main issues in the original.