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
Visualization Engine v3.0. (2019). Retrieved 19 September 2019, from https://visualize.data.gov.in/?inst=863a23cd-d1c7-45bc-af49-9372b0055077&vid=18901#
The following code was used to fix the issues identified in the original.
#importing the library
library(ggplot2)
library(tidyr)
library(tidyverse)
theme_set(theme_bw())
#reading the dataset.
forest_data <- read.csv("~/Downloads/Forest.csv")
#changing the column names
names(forest_data)[names(forest_data)=="State.of.Forest.Report.India.State.of.Forest.Report"] <- "Years"
names(forest_data)[names(forest_data)=="Forest.Cover"] <- "Forest_Cover"
#converting the "State.of.Forest.Report.India.State.of.Forest.Report" column to factor.
forest_data$Years <- factor(forest_data$Years, levels = forest_data$Years)
#function to convert exponential value to numeric value
fancy_scientific <- function(l) {
# turn in to character string in scientific notation
l <- format(l, scientific = TRUE)
# quote the part before the exponent to keep all the digits
l <- gsub("^(.*)e", "'\\1'e", l)
# turn the 'e+' into plotmath format
l <- gsub("e", "%*%10^", l)
# return this as an expression
parse(text=l)
}
#function to set the size of axis labels
My_Theme = theme(
axis.title.x = element_text(size = 8),
axis.text.x = element_text(size = 8),
axis.title.y = element_text(size = 8),
title = element_text(size = 8))
#1st Graph - Years vs Forest Cover in geographical Area
plot1 <- ggplot(data = forest_data, aes(group = 1, x = Years,y = Forest_Cover)) + geom_line(stat = "identity", colour = "tomato3") + geom_point(colour = "tomato3") + labs(
title = "Forest Cover of India from 1987 to 2015",
y = "Area in square kilometer") + theme_minimal() + scale_y_continuous(limits = c(0,500000) + scale_y_continuous(labels=fancy_scientific))
graph1 <- plot1 + My_Theme
#2nd Graph - Years vs percentage of forest cover
#using the ggplot() to plot the line graph for
plot2 <- ggplot(data = forest_data, aes(group = 1, x = Years,y = Percentage.of.forest.cover.to.the.total.geographical.area)) + geom_line(stat = "identity", colour = "turquoise3") + geom_point(colour = "turquoise3") + labs(
title = "Percentage Of Total Forest Cover Per Year",
y = "Percentage(%) of Forest Cover") + theme_minimal() + scale_y_continuous(limits = c(17,22))
graph2 <- plot2 + My_Theme
Data Reference
Visualization Engine v3.0. (2019). Retrieved 19 September 2019, from https://visualize.data.gov.in/?inst=863a23cd-d1c7-45bc-af49-9372b0055077&vid=18901#
The following plot fixes the main issues in the original.