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, It has been great to see the high level of engagement with my weekly critique videos on YouTube. I have really enjoyed making them and have learned a lot about current practices in data visualization. The one problem with these videos is that they’re a bit like an autopsy. We can figure out what went well or what didn’t work in a published figure. But we can’t do much to improve the published figure. What if we could do critiques before submitting our papers, preparing a...

Hey folks, This week I want to share with you a figure that resembles many a type of figure that I see in a lot of genomics papers. I’d consider it a data visualization meme - kind of like how you’re “required” to have a stacked bar plot if you’re doing microbiome research or a dynamite plot if you’re publishing in Nature :) This figure was included in the paper, “Impact of intensive control on malaria population genomics under elimination settings in Southeast Asia” that was published...

Hey folks! I hope you enjoyed last week’s series on the radial volcano plot (newsletter, critique video, livestream). I think it did a good job of illustrating the various reasons I think it’s valuable to recreate figures, even if we don’t like how they display the data. Something I didn’t really emphasize in last week’s newsletter was that by recreating a figure, we can make sure that the data are legit. I’m surprised by the number of signals I’ve been finding where authors using tools like...