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 posted two videos last week! On Monday I posted a video critiquing the diverging bar plot that I described in this newsletter last Friday. My goal in this video was to think through a “constructive” approach to interpreting and critiquing data visualizations. As scientists, I think we are too worried about hurting each other’s feelings. So we don’t critique each other. At the same time, many of us think before we speak and can come off overly harsh. My goal is to create a...

Hey folks! As I’m writing this newsletter the US government is in shutdown mode with no clear signs that things will get going anytime soon. I’ll withhold my own political take except to say that my family has been running without an official budget for about 25 years. I don’t recommend it, but we know basically how much money goes to our mortgage, insurance, groceries, charities, etc. and how much money we generally have left over. Somehow we still are able to spend money on living a pretty...

Hey folks! This week I have a figure for you from the New York Times based on a poll they did with Siena that describes Americans’ sentiments concerning Israel’s actions in their war with Gaza. What does it say to me? This plot is saying that more Americans think that Israel is intentionally killing civilians than they did in December 2023. The change in percentage of people in the other categories seems to decrease accordingly. What do you like? I love slope plots! I think they’re a great...