+ "markdown": "---\ntitle: \"Our World in Emissions | TidyTuesday\"\nauthor: \"Mitch Harrison\"\ncategories:\n - \"Data Viz\"\n - \"TidyTuesday\"\nimage: \"../../images/thumbnails/projects/tidytuesday/05212024.png\"\n---\n\n\nHello, all! Welcome to TidyTuesday. This week, as climate analysts often do, we \nare going to get mildly depressing in pursuit of a pretty graph. This time, we \nwill look at emissions from various actors' coal, natural gas, and cement \nproduction. Spoiler: it's not good.\n\nThe data for this week are brought to us by \n[Carbon Majors](https://carbonmajors.org), \nwho have compiled a database going all the way back to the 1850's! The dataset \ncontains emission data for 75 state and non-state actors, but we will aggregate \ninto total emissions by type for the plot. If you want to get more granular in \nyour own plot, check out the data on the TidyTuesday GitHub repository \n[here](https://github.com/rfordatascience/tidytuesday/tree/master/data/2024/2024-05-21)! \n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.r .cell-code}\nlibrary(tidyverse)\n\n# read data and rename an ugly column ------------------------------------------\nemis<- read_csv(paste0(\n \"https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/\",\n \"data/2024/2024-05-21/emissions.csv\"\n )\n)\n\nemis <- emis |>\n rename(emissions = \"total_emissions_MtCO2e\")\n\n# constants for ease of code legibility ----------------------------------------\nLEVS <- c(\"Coal\", \"Oil & NGL\", \"Natural Gas\", \"Cement\")\nBG_COLOR <- \"#F0F0F0\"\nGRAY <- \"gray35\"\nUN_TEXT <- paste(\n \"In 1995, the United Nations\\nConference of the Parties met for\\nthe first\", \n \"time to discuss the looming\\nthreat of climate change. The COP\\nhas\",\n \"met twenty-eight times since.\"\n)\n\n# data cleanup -----------------------------------------------------------------\nemis |>\n filter(year >= 1900) |> # lots of near-zero space without this filter\n mutate(\n commodity = if_else(str_detect(commodity, \"Coal\"), \"Coal\", commodity),\n commodity = factor(commodity, levels = LEVS) # re-order areas\n ) |>\n group_by(year, commodity) |>\n summarise(emissions = sum(emissions), .groups = \"drop\") |>\n \n # start of plot --------------------------------------------------------------\n ggplot(aes(x = year, y = emissions, fill = commodity)) +\n geom_area(alpha = 0.9) +\n \n # UN COP annotation text box -------------------------------------------------\n annotate(\n geom = \"segment\",\n x = 1995,\n xend = 1995,\n y = 35500,\n yend = 20500,\n linetype = \"solid\",\n linejoin = \"round\",\n linewidth = 1,\n color = \"grey35\",\n arrow = arrow(type = \"closed\", length = unit(0.2, \"cm\"))\n ) +\n annotate(\n geom = \"rect\",\n xmin = 1950.5,\n xmax = 1993.5,\n ymin = 23500,\n ymax = 35800,\n fill = BG_COLOR\n ) +\n annotate(\n geom = \"text\",\n x = 1992,\n y = 30000,\n label = UN_TEXT,\n color = GRAY,\n fontface = \"italic\",\n hjust = \"right\"\n ) +\n \n # replace legend with annotation text ----------------------------------------\n annotate(\n geom = \"text\",\n color = \"white\",\n x = 2020,\n y = c(1000, 4700, 13000, 26000),\n label = c(\"Cement\", \"Natural Gas\", \"Oil & NGL\", \"Coal\"),\n hjust = \"right\",\n fontface = \"bold\"\n ) +\n \n # visual style elements (love you, ggthemes) ---------------------------------\n ggthemes::scale_fill_colorblind() +\n ggthemes::theme_fivethirtyeight() +\n \n # customize axis breaks and labels -------------------------------------------\n scale_x_continuous(breaks = seq(1900, 2020, 20)) +\n scale_y_continuous(\n breaks = seq(0, 40000, 5000), \n label = scales::label_number(scale = 1e-3, suffix = \"k\")\n ) +\n labs(\n x = element_blank(),\n y = latex2exp::TeX(\"Emissions ($MtCO_2e$)\"),\n title = \"Our World in Emissions\",\n subtitle = latex2exp::TeX(\n paste(\n \"Emissions are measured in Millions of Tons of $CO_2$ equivalent\",\n \"($MtCO_2e$)\"\n )\n ),\n caption = paste(\n \"Made with love by Mitch Harrison\",\n \" \",\n \"Source: Carbon Majors database and TidyTuesday\"\n )\n ) + \n \n # theme cleanup --------------------------------------------------------------\n geom_hline(yintercept = 0, linewidth = 0.7, color = GRAY) + # bold axis\n theme(\n legend.position = \"none\", # hide legend\n axis.title.y = element_text(size = 10),\n plot.background = element_rect(fill = BG_COLOR)\n ) \n```\n\n::: {.cell-output-display}\n{fig-align='center' fig-alt='This plot is titled Our World in Emissions. It is an area plot that shows\nglobal emissions over time by type. The types are coal, natural gas,\ncement, and oil and NGL. The plot notes that in 1995, the UN first met to\ndiscuss the climate threat. The plot shows near-zero emissions from 1900 to\n1920, when a slow increase begins. From there, emission growth seems to be\nexponentially increasing, with no decline since the UN first met. Coal is\nthe largest emitter, then oil and NGL, then natural gas, and finally,\ncement.' width=768}\n:::\n:::\n\n::: {.cell}\n\n:::\n\n\n\nSo there she is! As we can see, the UN COP seems to be fighting an uphill \nbattle. Emissions are rising, but a good analyst must note the limitations of \nthe data. What jumps out to me is that renewables aren't listed here because \nit's only a graph of emissions. For all we know (from this graph), these \nemissions only produce a small portion of the world's energy, and we are arguing \nabout a couple of percentage points. Maybe we have defeated climate change after\nall!\n\nOf course, that's not the case, but proving that point will require outside \ndata. So, I welcome everyone reading to write a fuller report using more \nevidence. If nothing else, it would make for some fun data viz practice! \n\nIf you want a step-by-step guide to how I made this plot, there is a tutorial \npage [here](../../tutorials/tidytuesday_05212024.qmd), or even stop by my\n[Discord server](https://discord.gg/vF6W2bdKFH) and ask me! And, of course, \nif you appreciate my work enough to buy me a coffee, you can do so \n[here](https://buymeacoffee.com/mitchellharrison). \nThank you for reading, and see you next week!",
0 commit comments