This is a template file. The example included is not considered a good example to follow for Assignment 2. Remove this warning prior to submitting.
Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The visualisation was aimed at cricket fans who were looking forward to the World cricket cup and wanted to know which cities produced the best batters by total runs and averages.
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)
library(forcats)
library(dplyr)
Batting <- data.frame(Cities = c("Sydney", "Launceston",
"Cape Town", "Delhi", "Mumbai"),
Sum = c(5416, 2657, 4501, 3172,3938),
Avg = c(45.37, 44.80, 44.29, 36.53,35.51))
p1 <- ggplot(Batting, aes(x = reorder(Cities, -Avg), y = Sum, fill = Cities)) +
geom_col() +
guides(fill=FALSE) +
theme(legend.position="none")+
geom_text(aes(label = Sum), vjust = -0.2, colour = "Black") +
scale_fill_brewer(palette="Set2") +
ylab("Total Runs") +
xlab("Cities")+
geom_point(aes(x = reorder(Cities, -Avg), y = 50*Avg)) +
geom_text(aes(label=Avg, x=Cities, y=45*Avg)) +
scale_y_continuous(sec.axis = sec_axis(~./50, name = "Average Runs")) +
labs(title = "Cities with the best Batting averages",caption = "Data Source: ESPN Cricinfo")+
theme_bw()
Data Reference
The following plot fixes the main issues in the original.