This handout is a supplement to the Data Visualization with ggplot2 series of workshops given August–September 2019 at UGA’s DigiLab in the Main Library. Due to time constraints, the topics discussed here did not make it into the workshops, so I’ve moved them to this handout. As always, please visit for the latest materials.

1 Introduction

The previous workshop was called “Customizing your plots to make that perfect visual”, and after reviewing the material, it occured to me that you may not have all the tools you need to make that perfect visual. So, I wanted to include this supplement and show a few more ggplot functions. These are little things that can really help you make your plot your own.

Fair warning, this document likely won’t be as proofread as some of my other ones. The topics don’t really go together to form a cohesive theme for this workshop, other than being a bunch of miscelleneous ggplot2 topics. And this document will likely update as I learn about new things and want to throw them in somewhere. Just a hodge-podge of topics that I could potentially turn into workshops in the future.

## Warning: package 'ggplot2' was built under R version 3.5.2

1.1 Datasets and default plots

In this workshop, I’ll jump around from the various datasets used in previous workshops, so it’ll be a good idea to download them if you’d like to follow along.

Also, since the purpose of this workshop is to highlight lots of different nitty-gritty things, I’m going to start with some base plots—all based on ones you saw in previous workshops. As a way of doing shorthand, I’ll save the entire plots into an R objects, like p or s. That way, I can call those objects and add to them and it’ll be as if I typed those several lines of code.

1.1.1 Amount of sugar per McDonald’s category

For some of the workshop, I’ll work with the McDonald’s menu items dataset, which you can access from my wesite. To simplify things a little bit, I’ll take a subset—just four of the nine categories. To make that subset, I’ll use the subset function.

menu <- read.csv("")
menu_subset <- subset(menu, Category %in% c("Smoothies & Shakes", "Desserts", "Beverages", "Snacks & Sides"))

The default plot will just be the distribution of the number of sugars in each of the four remaining categories. For the color, I’ll use Paul Tol’s themes, which I access using the package ggthemes.

p <- ggplot(menu_subset, aes(Category, Sugars, fill = Category)) +
    geom_boxplot(size = 0.75) +
    geom_jitter(color = "gray15") + 

So now, to plot it, all I need to do is call p.