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.

Original


Source: Cities with the best batting talent.


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:

  • The colours are the same for the cities so it is difficult to distinguish which city straight away.
  • Instead of using images it would of been better to show the graph as a bar and dot chart to show the total runs and averages.
  • No y axis are in use which makes it difficult to know which city had the best batting run and average.

Reference

Code

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

Reconstruction

The following plot fixes the main issues in the original.