#Story Overview

Australia’s electricity industry is experiencing one of the largest energy transitions ever seen. Even though fossil fuels like coal and gas still make up the vast majority of electricity production and emissions, the rapid adoption of alternative energies such as wind, hydro, and solar power means that the energy landscape of Australia is changing. The purpose of this assignment is to look at Australia’s electricity industry through a number of data visualizations created with R, ggplot2, and Plotly.

With the help of publicly available electricity market data, this assignment looks at the trends of renewable energy usage, fossil fuel emissions, and the rising economic importance of clean energy within Australia’s electricity market. Using the principles of data storytelling, the aim was to create engaging and meaningful visualizations that would make complex data sets easier for an audience to understand.

#Load libraries
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
library(scales)
## 
## Attaching package: 'scales'
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## The following object is masked from 'package:readr':
## 
##     col_factor
library(lubridate)
library(viridis)
## Loading required package: viridisLite
## 
## Attaching package: 'viridis'
## 
## The following object is masked from 'package:scales':
## 
##     viridis_pal
#Load CSV

energy <- read.csv("C:/Users/Lenovo/Documents/3rd Sem(Assignments)/Assignment3(DV)/20250602 Open Electricity.csv")
#Data Cleaning

energy$date <- as.Date(energy$date)
#Select major electricity generation sources for energy mix analysis

energy_mix <- energy %>% select( date, Coal..Brown.....GWh, Coal..Black.....GWh, Gas..CCGT.....GWh, Hydro....GWh, Wind....GWh, Solar..Utility.....GWh, Solar..Rooftop.....GWh )
#Rename Columns

colnames(energy_mix) <- c( "date", "Coal Brown", "Coal Black", "Gas", "Hydro", "Wind", "Solar Utility", "Solar Rooftop" )
# CONVERT TO LONG FORMAT

energy_long <- energy_mix %>% pivot_longer( cols = -date, names_to = "source", values_to = "generation" )
#Chart 1
#Australia's Energy Mix is Changing

chart1 <- ggplot(
  energy_long,
  aes(
    x = as.Date(date),
    y = generation,
    fill = source
  )
) +

  geom_area(alpha = 0.92) +

  scale_fill_manual(values = c(
    "Coal Black" = "#383838",        # Charcoal
    "Coal Brown" = "#202020",        # Jet
    "Gas" = "#d8352a",               # Tomato
    "Hydro" = "#148cb8",             # Lapis Blue
    "Solar Rooftop" = "#feaa01",     # Mango Yellow
    "Solar Utility" = "#505aaf",     # Iris
    "Wind" = "#1f7a5c"               # Emerald
  )) +

  scale_y_continuous(labels = comma) +

  labs(
    title = "Australia’s Energy Transition Is Accelerating",
    subtitle = "Renewable energy sources are steadily reshaping the national grid",
    x = "Date",
    y = "Generation (GWh)",
    fill = "Energy Source"
  ) +

  theme_minimal(base_size = 13) +

  theme(
    plot.title = element_text(
      face = "bold",
      size = 18,
      colour = "#202020"
    ),

    plot.subtitle = element_text(
      size = 11,
      colour = "#4b4b4e"
    ),

    axis.title.y = element_text(
      face = "bold",
      colour = "#383838"
    ),

    axis.text = element_text(
      colour = "#4b4b4e"
    ),

    legend.title = element_text(
      face = "bold"
    ),

    panel.grid.minor = element_blank()
  )

ggplotly(chart1)
#Chart explanation:
#1)This chart depicts the evolving framework of Australia’s electricity generation system throughout the years. Although coal-based energy sources (Coal Black and Coal Brown) continue to play a substantial role in total electricity generation, renewable sources like wind, solar rooftop, and solar utility are progressively enhancing their share.

#2)The visualization emphasizes Australia’s gradual move away from reliance on fossil fuels towards cleaner renewable energy sources. Notably, the rise in solar and wind generation indicates a swift transition towards a more sustainable and lower-emission electricity system
# CHART 2
# SOLAR AND WIND ARE DRIVING THE TRANSITION

renewables <- energy %>%
  select(
    date,
    Wind....GWh,
    Hydro....GWh,
    Solar..Utility.....GWh,
    Solar..Rooftop.....GWh
  )

renewables_long <- renewables %>%
  pivot_longer(
    cols = -date,
    names_to = "source",
    values_to = "generation"
  )

chart2 <- ggplot(
  renewables_long,
  aes(
    x = as.Date(date),
    y = generation,
    color = source
  )
) +

  geom_line(linewidth = 1.15, alpha = 0.95) +

  scale_color_manual(values = c(
    "Wind....GWh" = "#1f7a5c",                   # Emerald
    "Hydro....GWh" = "#148cb8",                  # Lapis Blue
    "Solar..Utility.....GWh" = "#505aaf",        # Iris
    "Solar..Rooftop.....GWh" = "#feaa01"         # Mango Yellow
  )) +

  labs(
    title = "Renewable Energy Is Accelerating Rapidly",
    subtitle = "Renewable electricity generation continues to expand across the grid",
    x = "Date",
    y = "Generation (GWh)",
    color = "Renewable Source"
  ) +

  theme_minimal(base_size = 13) +

  theme(
    plot.title = element_text(
      face = "bold",
      size = 18,
      colour = "#202020"
    ),

    plot.subtitle = element_text(
      size = 11,
      colour = "#4b4b4e"
    ),

    axis.title.y = element_text(
      face = "bold",
      colour = "#383838"
    ),

    axis.text = element_text(
      colour = "#4b4b4e"
    ),

    legend.title = element_text(
      face = "bold"
    ),

    panel.grid.minor = element_blank()
  )

ggplotly(chart2)
#Chart Explanation:
#1)Australia's transition to renewable energy is no longer a distant goal — it is actively transforming the country's electricity system. This chart illustrates the steady growth of wind and solar generation throughout the observed timeframe, which has become increasingly integral to Australia's energy composition. While hydro generation remains relatively constant, wind energy consistently provides the largest renewable contribution, underscoring its rising significance in meeting national electricity demand.
#2)Simultaneously, both rooftop and utility-scale solar generation exhibit considerable growth, indicating a rising public embrace of clean energy technologies and substantial investment in renewable infrastructure. Collectively, these developments signify that renewable energy has evolved from being a supplementary electricity source to a dominant force propelling Australia’s shift away from fossil fuel reliance and towards a more sustainable energy future.
# CHART 3
# FOSSIL FUELS STILL DOMINATE EMISSIONS

emissions <- energy %>%
  select(
    date,
    Coal..Brown..Emissions.Vol...tCO.e,
    Coal..Black..Emissions.Vol...tCO.e,
    Gas..CCGT..Emissions.Vol...tCO.e
  )

emissions_long <- emissions %>%
  pivot_longer(
    cols = -date,
    names_to = "source",
    values_to = "emissions"
  )

chart3 <- ggplot(
  emissions_long,
  aes(
    x = as.Date(date),
    y = emissions,
    color = source
  )
) +

  geom_line(linewidth = 1.2, alpha = 0.95) +

  scale_color_manual(values = c(
    "Coal..Brown..Emissions.Vol...tCO.e" = "#5c4b3b",   # Warm dark brown
    "Coal..Black..Emissions.Vol...tCO.e" = "#202020",  # Jet black
    "Gas..CCGT..Emissions.Vol...tCO.e" = "#d8352a"     # Tomato red
  )) +

  scale_y_continuous(labels = comma) +

  labs(
    title = "Fossil Fuels still drive Emissions",
    subtitle = "Coal and gas remain major contributors to electricity-related carbon emissions",
    x = "Date",
    y = "Emissions Volume (tCO₂e)",
    color = "Fossil Fuel Source"
  ) +

  theme_minimal(base_size = 13) +

  theme(
    plot.title = element_text(
      face = "bold",
      size = 18,
      colour = "#202020"
    ),

    plot.subtitle = element_text(
      size = 11,
      colour = "#4b4b4e"
    ),

    axis.title.y = element_text(
      face = "bold",
      colour = "#383838"
    ),

    axis.text = element_text(
      colour = "#4b4b4e"
    ),

    legend.title = element_text(
      face = "bold"
    ),

    panel.grid.minor = element_blank()
  )

ggplotly(chart3)
#Chart Explanation:
#1)In spite of Australia’s swift advancements in renewable energy, fossil fuels still prevail in the nation’s carbon emissions landscape. This chart illustrates that coal-fired electricity generation — especially black coal — continues to be the primary source of electricity-related emissions during the observed timeframe. Brown coal also plays a significant role, further emphasizing the ongoing environmental impact of fossil fuel reliance within Australia’s energy sector.

#2)While gas emissions are relatively lower, they nonetheless contribute to the overall emissions intensity of the country. The enduring high levels of emissions indicate that, despite the growth in renewable energy capacity, Australia’s shift away from carbon-heavy electricity generation remains unfinished. Ultimately, the visualization underscores a crucial conflict in Australia’s energy transition: renewable energy is expanding rapidly, yet fossil fuels still maintain a significant influence in supplying the nation’s electricity and driving emissions.
# CHART 4
# THE ECONOMICS OF AUSTRALIA'S ENERGY MARKET

market <- energy %>%
  select(
    date,
    Wind.Market.Value...AUD,
    Hydro.Market.Value...AUD,
    Solar..Utility..Market.Value...AUD,
    Solar..Rooftop..Market.Value...AUD
  )

market_long <- market %>%
  pivot_longer(
    cols = -date,
    names_to = "source",
    values_to = "market_value"
  )

chart4 <- ggplot(
  market_long,
  aes(
    x = as.Date(date),
    y = market_value,
    color = source
  )
) +

  geom_line(linewidth = 1.15, alpha = 0.95) +

  scale_color_manual(values = c(
    "Wind.Market.Value...AUD" = "#1f7a5c",                # Emerald
    "Hydro.Market.Value...AUD" = "#148cb8",              # Lapis Blue
    "Solar..Utility..Market.Value...AUD" = "#505aaf",    # Iris
    "Solar..Rooftop..Market.Value...AUD" = "#feaa01"     # Mango Yellow
  )) +

  scale_y_continuous(labels = dollar) +

  labs(
    title = "The Rising Value of Renewables",
    subtitle = "Renewable energy sources are contributing increasing market value to Australia's electricity sector",
    x = "Date",
    y = "Market Value (AUD)",
    color = "Renewable Source"
  ) +

  theme_minimal(base_size = 13) +

  theme(
    plot.title = element_text(
      face = "bold",
      size = 18,
      colour = "#202020"
    ),

    plot.subtitle = element_text(
      size = 11,
      colour = "#4b4b4e"
    ),

    axis.title.y = element_text(
      face = "bold",
      colour = "#383838"
    ),

    axis.text = element_text(
      colour = "#4b4b4e"
    ),

    legend.title = element_text(
      face = "bold"
    ),

    panel.grid.minor = element_blank()
  )

ggplotly(chart4)
#Chart Explanation:
#1)Australia's shift towards renewable energy is not merely altering the composition of the country's electricity generation, but is also redefining the economic landscape of the energy market itself. This chart illustrates how renewable energy sources, including wind, hydro, and solar, are increasingly contributing to market value within Australia's electricity sector. Notably, hydro and wind sometimes witness substantial market surges, signifying times of heightened economic demand and profitability.

#2)Concurrently, both rooftop and utility-scale solar are enhancing their financial impact, indicative of rising investments in renewable infrastructure and greater involvement in clean energy markets. While market values may vary over time due to fluctuations in electricity demand and pricing conditions, the overarching trend indicates that renewable energy is becoming a more significant economic force within Australia's transforming energy system. Ultimately, this visualization underscores that the transition to renewable sources is not solely an environmental imperative, but also a significant economic opportunity that is shaping the future of Australia's electricity market.
# CHART 5
# CAN RENEWABLES OVERTAKE FOSSIL FUELS?

transition <- energy %>%
  mutate(
    renewable_total =
      Wind....GWh +
      Hydro....GWh +
      Solar..Utility.....GWh +
      Solar..Rooftop.....GWh,

    fossil_total =
      Coal..Brown.....GWh +
      Coal..Black.....GWh +
      Gas..CCGT.....GWh
  ) %>%
  select(date, renewable_total, fossil_total)

transition_long <- transition %>%
  pivot_longer(
    cols = -date,
    names_to = "type",
    values_to = "generation"
  )

chart5 <- ggplot(
  transition_long,
  aes(
    x = as.Date(date),
    y = generation,
    color = type
  )
) +

  geom_line(linewidth = 1.4, alpha = 0.95) +

  scale_color_manual(values = c(
    "renewable_total" = "#1f7a5c",   # Emerald Green
    "fossil_total" = "#202020"       # Jet Black
  )) +

  scale_y_continuous(labels = comma) +

  labs(
    title = "Can Renewables Overtake Fossil Fuels?",
    subtitle = "Australia's clean energy transition continues to accelerate",
    x = "Date",
    y = "Generation (GWh)",
    color = "Energy Category"
  ) +

  theme_minimal(base_size = 13) +

  theme(
    plot.title = element_text(
      face = "bold",
      size = 18,
      colour = "#202020"
    ),

    plot.subtitle = element_text(
      size = 11,
      colour = "#4b4b4e"
    ),

    axis.title.y = element_text(
      face = "bold",
      colour = "#383838"
    ),

    axis.text = element_text(
      colour = "#4b4b4e"
    ),

    legend.title = element_text(
      face = "bold"
    ),

    panel.grid.minor = element_blank()
  )

ggplotly(chart5)
#Chart Explanation:
#1)Australia's electricity transition is nearing a pivotal moment. This chart illustrates the comparison between total renewable energy generation and fossil fuel generation, demonstrating how the disparity between these two energy categories is progressively diminishing over time. At the outset of the observed timeframe, fossil fuels clearly dominate Australia's electricity landscape, generating substantially more energy than renewables.

#2)Nevertheless, as wind, hydro, and solar energy production continue to grow, renewable energy consistently enhances its share in the national grid. Throughout various intervals, renewable generation starts to near — and at times even rival — fossil fuel output levels. Despite these advancements, fossil fuels still hold a predominant position, underscoring the ongoing reliance on coal and gas within Australia's energy framework. Ultimately, the visualization encapsulates the core narrative of Australia's energy future: renewables are swiftly advancing, yet the shift away from fossil fuels remains a protracted and fiercely debated transformation.