(Don't go chasing) waterfall charts


Hey folks,

I really enjoyed teaching a one-day, introduction to ggplot2 workshop last week. It was a lot of fun - I enjoyed teaching the principles behind ggplot2. I’ve been noticing many learners (and teachers) focusing on making templates that they can recycle to make variations on a common plot type. This is how I often teach ggplot2 and the rest of the tidyverse - it’s also how I learned R. In the most recent workshop I was testing a hypothesis that teaching concepts would yield more long term learning gains than the template approach. I’d love to work out some of the kinks and teach it again. Let me know if you’d be interested in learning by this alternative approach.


If you’re a late-Gen Xer like me, the word “waterfall” will instantly queue up in your mind the song “Waterfalls” by TLC. Whenever I see a waterfall chart, I think of this song. Sorry. Not sorry :)

Anyway, last week I found this waterfall chart in a Washington Post article on the 0.3% drop in the US GDP during the first quarter of 2025.

Waterfall charts are helpful for depicting the cumulative effect of positive and negative components. For the GDP, personal consumption, private investment, government spending, and exports typically count in the positive direction and imports in the negative direction. For the first quarter, government spending was down a smidge, leading to a similar decrease in GDP. I was able to gather these data from the data linked through the Bureau of Economic Analysis.


R library(tidyverse)
tribble(~category, ~change,
    “personal_consumption”, 1.8,
    “private_investment”, 21.9,
    “gov_spending”, -1.4,
    “exports”, 1.8,
    “imports”, 41.3
)

I thought this would be a great plot to share with you all. I instantly started thinking about how I would create this in R. This plot has a few cool things going on.

First, there are vertical line segments with arrows. I would create these using geom_segment() with the arrow argument. Each category would have its own x and xend arguments, but these values would be the same within the same category. They would also have a starting and ending y position argument; the ending position having the arrow head. Thinking of the data I shared above in the tribble, I would likely calculate the cumulative change to create y value and lag that to generate the yend values.

Second, there are the bars. Normally when I see these rectangles I think, “bar plot!”. But bar plots start at 0 on the y-axis. These bars start at different locations for each category similar to the arrows. Instead, I’d either use geom_rect() to draw rectangles or I’d generate another line segment, but make them very thick to match the rectangle. Hmmm. I wonder which would be easiest to try out.

Third, each rectangle has a solid black line at either end to indicate the top and bottom edge. I’d likely do this with geom_segment().

Let’s pause here for a moment… Could I generate this waterfall chart using only geom_segment()? I would use the function in three different ways. I think this sounds like a cool challenge.

Next, there’s annotation for each piece of the waterfall where the category label is bolded and colored like the bar. The rest of the text is in a regular black font. The labels vary in how the text is justified. Because of the combination of font faces and colors, I’d likely use geom_richtext() from the {ggtext} package.

Finally, there are also the grid lines. At first appearances they look normal. But, the grid line that intercepts the y-axis at +1 is on top of the “Personal consumption” segment and behind the “Imports” segment. All the other grid lines are behind their segments… why?! I think this is silly. If I wanted to follow this faithfully, I’d likely use the background grid lines that are controlled with the theme(panel.grid) arguments. Then I’d either draw a fourth segment on top of the “Personal consumption” segment. Hey, that’s a fourth geom_segment()!

Let me know what you think of this type of plot. Have you seen waterfall charts in your work? I’d love to see more examples.

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, As I mentioned last week, I’m exploring the possibility of holding live, in person, workshops again like I did before the pandemic. If this is something that interests you, please let me know. My thought would be to hold them at an affordable hotel near the Detroit airport (DTW). But, if you would like to host me to teach a workshop, I would be open to that as well. This week, I want to call your attention to a plot that I would not encourage you to make. This comes form “Targeted...

Hey folks! I’m hoping to host two workshops in March and April. The first would be a Zoom-based workshop on the principles of data visualization (I taught a version of this last month). This would be a code-free workshop and would run for about 3 hours. I don’t have a date yet. If you are interested, please reply to this email and let me know if there is a date and time in March that would work best for you. The second would be an in person 3 day workshop taught near the Detroit airport. I...

Hey folks, We had a lot of fun last week with my first workshop on the theory of data visualization! If this is something that you’d be interested in participating in let me know. At this point, I don’t have anything scheduled. So, if you have suggestions for days or times, please let me know This week I have a fun figure to share with you from a paper recently published in Nature Microbiology, titled, “Candida auris skin tropism and antifungal resistance are mediated by carbonic anhydrase...