New workshop & Plotting things that have changed over the past 5 years


Hey folks,

I somehow got through the month of March without a plot to commemorate the 5th anniversary of the COVID-19 pandemic. It is hard to believe that it has been five years. I know that my life and how I work has radically changed because of the pandemic. I started posting videos to YouTube and writing newsletters during the pandemic to help people who wanted to learn to use R while they were locked out of their labs. At one point I taught a workshop for U of Michigan researchers that had over 100 participants. That nearly broke me!

Well if you or a friend are interested in taking a workshop I have something new to announce. On May 9th I will be teaching a live, one-day workshop on the basics of the ggplot2 R package and the grammar of graphics. It will be taught via Zoom (remember Skype or BlueJeans!?!) and is designed for people new to R or ggplot2. I hope to give people a mental model for thinking about ggplot2 that will enable them to continue learning about the tool well beyond the workshop. You can learn more and register by clicking the button below. Feel free to email me if you have any questions.

Let me know if you’d like to see other one or part day workshops offered related to the types of things I discuss in the newsletter or over on YouTube.


On the topic of things that have changed because of the pandemic, the New York Times published a cool article. The article, “30 Charts That Show How Covid Changed Everything” includes 30 charts showing different aspects of life that have changed before and after March 2020. There are a few plots that I thought were fascinating, so I might make two of these on YouTube in the coming weeks.

For this newsletter, the last visual in the series really struck me. The number of “Total U.S. deaths” from 2015 to 2025

It was obvious that the number of deaths spiked in the years after the pandemic. But I was struck that although the periodicity of deaths has returned to a pre-pandemic cadence, the average number of deaths per week is still higher than it was pre-pandemic. Aside from the story told by this visual, a few things stood out to me that I wondered how I would make in R.

This is obviously a line plot. I imagine that I can get the number of deaths per week from the CDC and that data would have a date column and a number of deaths column. To get a two toned line, I’d create a new column based on whether the date was before or after March 2020. Then I’d map that column to the color aesthetic, the date to the x aesthetic, and the number of deaths to y aesthetic. I’d make the line plot using geom_line(). By now, we have a number of examples on how to make the “New York Times” y-axis, customizing colors, and so forth.

I think the element of this plot that really got my attention was the two toned background. I never see that. The entire left side of the article is a gray color (#EEEEEE) and the right is a red color (#FCF0E9). If you look closely, there is a white center line. How would we do that in a figure so that even the background has two colors? Here’s what I would do. First, I would use theme(plot.background = element_rect(fill = "#EEEEEE")) to make the background the gray color. Then, I’d use theme(panel.background = element_blank()) to remove all background color from the panel where data are displayed. Then, I’d use geom_rect() to draw a rectangle with xmin corresponding to March 2020, xmax corresponding to 2030 (a year to the right of the plot), ymin to -1000 (a value well below the plotted values), and ymax to 1000000 (a value well above the plotted values). I’d use fill = "#FCF0E9" and color = "white". On its own, this will give us a two toned panel, but not overall plot. To get it to work for the entire plot, I’d use coord_cartesian() with clip = "off" to show the rest of the rectangle. I was so excited to see if this would work that I tried a simple example…


library(tidyverse)
tibble(x = c(1, 5),
       y = c(5, 1)) %>%
  ggplot(aes(x = x, y = y)) +
  geom_rect(xmin = 3, xmax = 8, ymin = -1, ymax = 8,
            fill = "#FCF0E9", color = "white") +
  geom_line() +
  coord_cartesian(clip = "off") +
  labs(x = NULL, y = NULL, title = "Factor") +
  theme(plot.background = element_rect(fill = "#EEEEEE"),
        panel.background = element_blank())

It worked! Run it and see for yourself.

Next, I liked the use of the reference line for the 2015-2019 average. I’d likely get that using dplyr using the summarize() function to get the average weekly deaths for the group of dates from before the pandemic. Then I’d plot that average using geom_hline(). I recently learned from a viewer that we can have greater control over the linetype argument by using hexadecimal characters to indicate the length of the dash and the length of the space. For example, this looks like it could be linetype = "22".

Finally, the simple title in the upper right corner stood out to me. I never think about the background color of my title because I’m always working with a white background. But… the plot.title argument in theme() takes element_text(), which doesn’t allow you to change the background color. Hmmmm. Instead, I would use the {ggtext} package’s element_textbox_simple() function to style the title by giving it a white background. I’m not always a fan of the constellation of {ggplot}-related packages, but really love the {ggtext} package.

Give the 30 charts in the article a scan. Let me know if there’s one that sticks out to you that you would like me to try to recreate.

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...