Visualizing contributions to global CO2 production along side the Financial Times


Hey folks,

This week I have an interesting figure for you from the Financial Times from an e-mail newsletter they distribute each week describing some visualization related to climate change.

Before reading further, go ahead and spend a few minutes with the image. What does it say to you? What do you like? What don’t you like about it? How do you think you would go about making it in R? I’d encourage you to write down any of your answers to these questions before reading what I have to say. It would be awesome if you could send me your responses just to get a sense of what other people see (feel free to reply to this email!)

What does it say to me? I like the declarative title that “China accounts for almost a third of the current global emissions with a cumulative share of 16%”. What do you like? I’m not a huge fan of stacked area plots, but they did a nice job of focusing on a set of countries/regions of interest. Too often I see people try to include too many categories leading to too many colors, which makes it impossible to know which color belongs to each country. What don’t you like? All that being said, I think the legend could have been better embedded into the panels so that one doesn’t have to scan back and forth. Also, the colors are basically reddish and greenish. I get that EU27, Russia, and UK are all European-ish and could be similar colors. But why are China and US similar colors? In addition to labelling the areas directly, I’d try to pick five distinct colors. How would I make this in R? Good question! I can think of a hack approach and a more elegant approach.

The hack would be to create two sets of data that are either scaled by year or over the past 175 years. Then I would use facet_wrap() to make two panels. I’d try to use scales = "free" to limit the x and y-axis limits. Like I said, I think this is a bit of a hack. It’s always hard to work with facets that have different axis limits, much less two different axis limits.

The more elegant approach would be to use {patchwork}. I’d create the two panels and then compose them together. The {patchwork} package has tooling to gather the legends into a common legend. I’m pretty sure we can also give each subplot its own title while having an overall title, subtitle, and caption.

Regardless of the approach to making the two panels, each panel has a stacked area plot. We can use {ggplot2}’s geom_area() function to make these plots.

Happily, I was able to find the data! If you go to the data hub of the Global Carbon Budget, we can download an xlsx-formatted version of the data from the second link on the data archive page. The second link is titled “National fossil carbon emissions v2023”. That workbook has multiple tabs and the one we want is “Territorial Emissions”. The data span from 1850 to 2023 and there are 230 columns. Those columns represent individual countries, groups of countries (e.g., EU27), and the “World”.

To get the data into R, I’d use the {readxl} package to read in the data from the desired tab and remove the first 11 lines of header rows. We could use select to get the countries, EU27, and world total. From those data we can calculate the carbon production from “Other” countries. To tidy the data we’d use pivot_longer() to make a column for the year, territory, and carbon production. The header for the tab mentions that we will want to multiply the carbon production data by 3.664 to convert to tonnes of CO2. We could divide by 1 million to get the number of Gt CO2 used in the left-hand panel. A small detail for the left-hand panel is that the data only go back to 1950 (or so). We’d use filter on those data to remove the first 100 years worth of data. For the right-hand panel, the cumulative historical share can be calculated by using cumsum() and dividing by the cumulative sum for the world and multiplying by 100%.

This would be my general approach. What did you come up with? Any preference for trying to do this with facet_wrap() or {patchwork}? Stay tuned for a future YouTube video when I try to implement this figure. I may try it both ways to see what works best. It might end up being a mess, but it’ll be fun!

Workshops

I'm pleased to be able to offer you one of three recent workshops! With each you'll get access to 18 hours of video content, my code, and other materials. Click the buttons below to learn more

In case you missed it…

Here is a livestream that I published this week that relate to previous content from these newsletters. Enjoy!

video preview

Finally, if you would like to support the Riffomonas project financially, please consider becoming a patron through Patreon! There are multiple tiers and fun gifts for each. By no means do I expect people to become patrons, but if you need to be asked, there you go :)

I’ll talk to you more next week!

Pat

Riffomonas Professional Development

Read more from Riffomonas Professional Development

Hey folks! I’m in proposal writing mode again. Unfortunately, I am finding my weekly search for a data visualization to share with you is leading me down unproductive internet rabbit holes. So, I thought I’d share an idea with you that I hope resonates. If you have any reactions, please send them my way! For the past year or so I have been recreating other people’s data visualizations in an attempt to learn new techniques with R and expand the type of data that I normally visualize. The idea...

Hey folks! Here in the US, vaccines continue to be a hot button issue. I feel like this issue is really an amalgamation of multiple issues including the decline in respect for authority figures, frustration with COVID, inability to assess risk at a personal level, and parents feeling like they are losing rights. Do people really want their kids to get sick unnecessarily? I doubt it. It’s also in the news because the Secretary of Health and Human Services is a vaccine skeptic/denier with many...

Hey folks! Sorry for the hiatus in getting you a newsletter into your inbox. The end of the summer/beginning of the academic year has been pretty chaotic. Actually, I had what I thought would be an interesting plot to recreate, but then I wasn’t able to find the original data and I wasn’t really interested in simulating it. Oh well. I’m also finding it hard to come up with interesting data visualizations from out in the wild. One of my go-to’s, Philip Bump, stopped working for the Washington...