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’ve really enjoyed the flow of combining these newsletters with a Monday critique video, a Wednesday recreation video, and occasionally a Friday remake video. A few weeks in, I feel pretty good about our ability to engage in constructive critiques. Of course, we have to train ourselves (myself included) to use those tools and not just resort to immediate and emotional responses - “I hate that plot”. We need to engage, get in the head of the original creator, and try to understand...

Hey folks! I’m appreciating the positive feedback on Monday critique videos. They’re a lot of fun to think through and make. I think I might start looking at figures that are drawn from the scientific literature since many of you found out about me from my science work. Let me know if there are plots or practices that you’d like to see me talk about. I’ll see if I can work them into the queue. Also, if you’re working on developing figures for a presentation, poster, or paper and would like to...

Hey folks! I continue to get positive feedback about my critique videos. This has me quite excited that I’ve perhaps scratched an itch that people have been struggling with. Would you like to meet with a group of other people who are committed to making their data visualizations better? I’m forming groups now that would meet once a week or every other week to give each other constructive feedback on the visualizations they are making for their work. Alternatively, if you have ever thought, “I...