Our World in Emissions | TidyTuesday

Data Viz
TidyTuesday
Author

Mitch Harrison

Hello, all! Welcome to TidyTuesday. This week, as climate analysts often do, we are going to get mildly depressing in pursuit of a pretty graph. This time, we will look at emissions from various actors’ coal, natural gas, and cement production. Spoiler: it’s not good.

The data for this week are brought to us by Carbon Majors, who have compiled a database going all the way back to the 1850’s! The dataset contains emission data for 75 state and non-state actors, but we will aggregate into total emissions by type for the plot. If you want to get more granular in your own plot, check out the data on the TidyTuesday GitHub repository here!

Click here for code
library(tidyverse)

# read data and rename an ugly column ------------------------------------------
emis<- read_csv(paste0(
  "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/",
  "data/2024/2024-05-21/emissions.csv"
  )
)

emis <- emis |>
  rename(emissions = "total_emissions_MtCO2e")

# constants for ease of code legibility ----------------------------------------
LEVS <- c("Coal", "Oil & NGL", "Natural Gas", "Cement")
BG_COLOR <- "#F0F0F0"
GRAY <- "gray35"
UN_TEXT <- paste(
  "In 1995, the United Nations\nConference of the Parties met for\nthe first", 
  "time to discuss the looming\nthreat of climate change. The COP\nhas",
  "met twenty-eight times since."
)

# data cleanup -----------------------------------------------------------------
emis |>
  filter(year >= 1900) |> # lots of near-zero space without this filter
  mutate(
    commodity = if_else(str_detect(commodity, "Coal"), "Coal", commodity),
    commodity = factor(commodity, levels = LEVS) # re-order areas
  ) |>
  group_by(year, commodity) |>
  summarise(emissions = sum(emissions), .groups = "drop") |>
  
  # start of plot --------------------------------------------------------------
  ggplot(aes(x = year, y = emissions, fill = commodity)) +
  geom_area(alpha = 0.9) +
  
  # UN COP annotation text box -------------------------------------------------
  annotate(
    geom = "segment",
    x = 1995,
    xend = 1995,
    y = 35500,
    yend = 20500,
    linetype = "solid",
    linejoin = "round",
    linewidth = 1,
    color = "grey35",
    arrow = arrow(type = "closed", length = unit(0.2, "cm"))
  ) +
  annotate(
    geom = "rect",
    xmin = 1950.5,
    xmax = 1993.5,
    ymin = 23500,
    ymax = 35800,
    fill = BG_COLOR
  ) +
  annotate(
    geom = "text",
    x = 1992,
    y = 30000,
    label = UN_TEXT,
    color = GRAY,
    fontface = "italic",
    hjust = "right"
  ) +
  
  # replace legend with annotation text ----------------------------------------
  annotate(
    geom = "text",
    color = "white",
    x = 2020,
    y = c(1000, 4700, 13000, 26000),
    label = c("Cement", "Natural Gas", "Oil & NGL", "Coal"),
    hjust = "right",
    fontface = "bold"
  ) +
  
  # visual style elements (love you, ggthemes) ---------------------------------
  ggthemes::scale_fill_colorblind() +
  ggthemes::theme_fivethirtyeight() +
  
  # customize axis breaks and labels -------------------------------------------
  scale_x_continuous(breaks = seq(1900, 2020, 20)) +
  scale_y_continuous(
    breaks = seq(0, 40000, 5000), 
    label = scales::label_number(scale = 1e-3, suffix = "k")
  ) +
  labs(
    x = element_blank(),
    y = latex2exp::TeX("Emissions ($MtCO_2e$)"),
    title = "Our World in Emissions",
    subtitle = latex2exp::TeX(
      paste(
        "Emissions are measured in Millions of Tons of $CO_2$ equivalent",
        "($MtCO_2e$)"
      )
    ),
    caption = paste(
      "Made with love by Mitch Harrison",
      "                                                                       ",
      "Source: Carbon Majors database and TidyTuesday"
    )
  ) + 
  
  # theme cleanup --------------------------------------------------------------
  geom_hline(yintercept = 0, linewidth = 0.7, color = GRAY) + # bold axis
  theme(
    legend.position = "none", # hide legend
    axis.title.y = element_text(size = 10),
    plot.background = element_rect(fill = BG_COLOR)
  ) 

This plot is titled Our World in Emissions. It is an area plot that shows global emissions over time by type. The types are coal, natural gas, cement, and oil and NGL. The plot notes that in 1995, the UN first met to discuss the climate threat. The plot shows near-zero emissions from 1900 to 1920, when a slow increase begins. From there, emission growth seems to be exponentially increasing, with no decline since the UN first met. Coal is the largest emitter, then oil and NGL, then natural gas, and finally, cement.

So there she is! As we can see, the UN COP seems to be fighting an uphill battle. Emissions are rising, but a good analyst must note the limitations of the data. What jumps out to me is that renewables aren’t listed here because it’s only a graph of emissions. For all we know (from this graph), these emissions only produce a small portion of the world’s energy, and we are arguing about a couple of percentage points. Maybe we have defeated climate change after all!

Of course, that’s not the case, but proving that point will require outside data. So, I welcome everyone reading to write a fuller report using more evidence. If nothing else, it would make for some fun data viz practice!

If you want a step-by-step guide to how I made this plot, there is a tutorial page here, or even stop by my Discord server and ask me! And, of course, if you appreciate my work enough to buy me a coffee, you can do so here. Thank you for reading, and see you next week!