Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The visualisation chosen had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
library(readr)
library(dplyr)
library(ggplot2)
# Reading the data from csv file
roadAccidentIndia<- read_csv("roadAccidentIndia.csv")
# Flitering the data from Year 1994
roadAccidentIndia <- roadAccidentIndia %>% filter(roadAccidentIndia$Years>=1994)
p1 <- ggplot(roadAccidentIndia,
aes(x = factor(`Years`),
y = `Total Number of Road Accidents (in numbers)`,
group = 1 )) +
ggtitle("Road Accidents in India from 1994 to 2017") +
xlab("Year") +
ylab("Total Number of Road Accidents (in numbers)") +
geom_line(stat = "identity",size= 1,colour="#396ACB") +
geom_point(colour="#396ACB") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(size = 7)) +
scale_y_continuous(limits = c(300000,550000))
p2 <- ggplot(roadAccidentIndia,
aes(x = factor(`Years`),
y = `Number of Accidents per Lakh Population`,
group = 1)) +
ggtitle("Number of Accidents per Lakh Population in India from 1994 to 2017")+
xlab("Year") +
ylab("Number of Accidents per Lakh Population") +
geom_line(colour="#CA4E55",size=1) +
geom_point(colour="#CA4E55") +
theme(panel.background = element_rect(fill = "white", colour = "grey50"),
plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(size = 7)) +
scale_y_continuous(limits = c(35,45))
Data Reference
The following plot fixes the main issues in the original.