Tips and Tricks

Recreating Financial Times Data Viz of 2024 US Presidential Election
December 5, 2024
A couple weeks ago, in the wake of the presidential election here in the United States, everyone was looking for explanations for the results. One of the most compelling reasons that Donald Trump won came from John Burn-Murdoch . Burn-Murdoch, a columnist and the chief data reporter at the Financial Times, posted this graph showing that incumbents around the world had fared extremely poorly in 2024 . This graph got a ton of attention online not only because the data that underlies it strongly...

An introduction to the {gganimate} package
November 27, 2024
The {gganimate} package is the easiest way to make animated plots in R. If you know how to make plots in ggplot, you can animate them with {gganimate}. Animated plots are a great way to capture attention, especially online where the next shiny object is just a scroll away. If you want to get attention on your data, using animation with a package like {gganimate} is a great option. In this blog post, I’ll show how to use the {gganimate} package by animating data on refugees. As part of our one...

Use vertical white lines instead of axis lines for cleaner charts
November 21, 2024
I recently came across a data viz in the New York Times that used a unique approach to adding axis lines. In this chart about the number of days that members of the United States House of Representatives served as speaker , rather than use traditional axis lines, they used white lines that show up on bars but are hidden otherwise. How can we create a bar chart in ggplot2 without using vertical white lines? This guide will walk you through the steps to create a polished bar plot using gross...

Use smart labeling in ggplot to help your audience understand your graphs
October 24, 2024
When making data viz in R, it’s easy to think that adding label to everything will make your charts easier to understand. This is rarely the case. Instead, when making charts, maps, etc with ggplot, your best bet is to label smartly. Only labeling the most important pieces of your data viz ensures that your audience will grasp what you want them to grasp. In this blog post, I’ll show you how to use smart labeling in ggplot to help your audience understand your graphs. The issue of smart...

Today I Learned in R: the {shadowtext} package
October 17, 2024
If you spend time on YouTube looking at R content, you may have come across Andrew Gard of the Equitable Equations channel and Greg Martin from R Programming 101 . Together, they do a series called Today I Learned in R . They asked me to come on recently to share an R tip. In my conversation with Andrew and Greg, I shared one of my favorite packages: {shadowtext} . I showed them how we use {shadowtext} to ensure that text is easy to read in all situations.

How to Make a Thousand Plots Look Good: Data Viz Tips for Parameterized Reporting
September 26, 2024
In June 2024, I gave a talk at Cascadia R Conference about making high-quality data viz when doing parameterized reporting . It's something we do a lot in our consulting work . I recorded myself prepping for the talk, which you can see here. If you want to see a recording of the talk given at the conference, check out the Cascadia R Conf YouTube page . Slides Talk Abstract Data visualization is complicated enough when you are making one plot. Now imagine you're making multiple plots in...

Data viz tips for parameterized reporting: set consistent axis limits
August 1, 2024
One of the biggest challenges we face when doing parameterized is how to make plots consistent across multiple reports. We’ve learned (oftentimes the hard way) many tricks for dealing with this problem. One I want to share with you today is making your axis limits consistent when making multiple plots. Here’s an example of a plot that shows median income by county for the annual Oregon by the Numbers . Let me show you a simplified version of the function I created to make these plots. We’ll...

How to make polished population pyramids in ggplot: part 2
July 18, 2024
I wrote recently about how I revamped the process of making population pyramids for Oregon by the Numbers , the report I’ve worked on for the last several years. Rather than making one plot, I used the patchwork package to stitch together three parts: A plot for women on the left Age labels in the center A plot for men on the right The result is a polished version of a population pyramid that I’m quite pleased with. The blog post I wrote about making this version of the population pyramid saw...

Animated versions of common dplyr functions
July 17, 2024
One of the best parts about the functions in the dplyr package (one of several that make up the tidyverse collection of packages) is that their names indicate what they do. No need to remember a weird acronym; the name of the function to filter your data is filter() . But, helpful as these function names are, it can still be hard to remember exactly what the functions do. In remaking my Fundamentals of R course in 2023, I had Albert Rapp generate animated versions of the most common...