Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The original 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) # Useful for data maipulation
library(tidyr) # Useful for tidying data
library(ggplot2)
# library(knitr) # Useful for creating nice tables
rm(list=ls())
# Electricity annual consumption by opertional
df_esoo <- read.csv("ESOO_2019.csv")
# Rename the columns to proper names
df_esoo <- df_esoo %>% rename(Annual_Consumption = Annual.consumption..GWh.)
# Filter the appropriate columns and required data
df_esoo_plot <- df_esoo %>% select(Region, Year, Category, Scenario, Annual_Consumption) %>% filter(Year>= 2020, Scenario %in% c("Central"),(Region %in% c("NEM")), !(Category %in% c("Total")))
# Aggregate the value by Year, Operational Category
df_esoo_plot_year <- df_esoo_plot %>% group_by(Year, Category) %>% summarize(Consumption = sum(Annual_Consumption))
# str(df_esoo)
# df_esoo_plot_year
# Min-Max Year for x-axis
min_year = min(df_esoo_plot_year['Year'])
max_year = max(df_esoo_plot_year['Year'])
# 0-Max Consumption for y-axis
max_consumption = max(df_esoo_plot_year['Consumption'])
# PLot for ESOO
plot_esoo <- ggplot(data=df_esoo_plot_year, aes(x=Year, y=Consumption, group=Category, shape=Category, color=Category)) +
geom_line() +
geom_point() +
geom_vline(xintercept = seq(min_year,max_year, 5))+
scale_x_continuous(name="Year", breaks = c(seq(min_year,max_year, 2),max_year)) +
scale_y_continuous(name="Annual Consumption (GWh)", breaks = seq(0, max_consumption, 20000)) +
ggtitle("Electricity Annual Consumption Operational") +
theme_minimal() +
theme(legend.position="bottom", plot.title = element_text(hjust = 0.5), axis.text.x = element_text(angle=45))
# plot_esoo
# Gas annual consumption by opertional
df_gsoo <- read.csv("GSOO_2020.csv")
df_gsoo <- df_gsoo %>% rename(Annual_Consumption = Annual.consumption..PJ.)
# Filter the appropriate columns and required data
df_gsoo_plot <- df_gsoo %>% select(Region, Year, Category, Scenario, Annual_Consumption) %>% filter(Year>= 2020, Scenario %in% c("Central"),(Region %in% c("ALL")), !(Category %in% c("Total")))
# Aggregate the value by Year, Operational Category
df_gsoo_plot_year <- df_gsoo_plot %>% group_by(Year, Category) %>% summarize(Consumption = sum(Annual_Consumption))
# str(df_gsoo)
# df_gsoo_plot_year
# Min-Max Year for x-axis
min_year = min(df_gsoo_plot_year['Year'])
max_year = max(df_gsoo_plot_year['Year'])
# 0-Max Consumption for y-axis
max_consumption = max(df_gsoo_plot_year['Consumption'])
# PLot for GSOO
plot_gsoo <- ggplot(data=df_gsoo_plot_year, aes(x=Year, y=Consumption,group=Category, shape=Category, color=Category)) +
geom_line() +
geom_point() +
geom_vline(xintercept = c(seq(min_year,max_year, 5),max_year))+
scale_x_continuous(name="Year", breaks = c(seq(min_year,max_year, 2),max_year)) +
scale_y_continuous(name="Annual Consumption (PJ)", breaks = seq(0, max_consumption, 200)) +
ggtitle(label = "Gas Annual Consumption Total") +
theme_minimal() +
theme(legend.position="bottom",plot.title = element_text(hjust = 0.5), axis.text.x = element_text(angle=45))
# plot_gsoo
Data Reference
The following plot fixes the main issues in the original.