Skip to content
R for the Rest of Us Logo

Try New Plot Types

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window


Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

  • Use one of the packages above to make a unique plot. For example, you might use dumbell plots in the ggalt package to show change in the Hispanic/Latino population from 2017-2018 to 2018-2019 for all districts.

  • When you finish your plot, email it to me at [email protected]! I’d love to see what you come up with.

Heads up: You likely want to watch the solutions video because it involves reshaping the data to make it work with the ggalt package.

Learn More

You can see all of the geoms built into ggplot here.

The documentation websites for the packages discussed in this lesson are below:

To learn more about other things that. arepossible with ggplot, check out the awesome ggplot2 GitHub repository , which has a list of a lot of other great ggplot extensions to try out!

I'd also recommend looking at the Data to Viz website , which lists various visualization options and provides sample R code for each.

Finally, if you're not already following Tidy Tuesday , check it out! Every week, a new data set is released, which people then analyze and visualize. They post their results using the #TidyTuesday hashtag. The most incredible thing is that people often post their code alongside their visualizations so you can see how they did what they did.

Three regular Tidy Tuesday contributors I'd recommend following (their work is exceptional and they always post their code) are:

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Atlang Mompe

Atlang Mompe

June 24, 2021

Hi David, I have loaded the janitor package like you did and ran the code on the solution just to see if it works but I get this error: Error in geom_dumbbell(colour_x = "gray", colour = "gray", colour_xend = "blue", : could not find function "geom_dumbbell" >

David Keyes

David Keyes Founder

January 9, 2022

I do! The code to make it is here. I found this plot on Twitter originally.

David Keyes

David Keyes Founder

January 11, 2022

Yup, it's the best!

So, I tried re-creating the solution here, and despite changing various things, both the x and xend seem to be getting plotted at -1.0 ?

This is the code I've gotten to now - I was mostly changing bits to see what was broken and what the result of the changes was..

enrollment_by_race_ethnicity %>% filter(race_ethnicity == "White") %>% select(-c(race_ethnicity, number_of_students, district_id)) %>% pivot_wider(id_cols = district, names_from = year, values_from = percent_of_total_at_school)%>% slice(1:10)%>% ggplot(aes(x = 2017-2018, xend = 2018-2019, y = district, yend = district)) + geom_dumbbell(colour_x = "gray", colour = "gray", colour_xend = "red", size_x = 10, size_xend = 1.5) + theme_jd() + scale_x_continuous()

This is a link to the image it's producing ....

thanks for any suggestions!

Andrew Paquin

Andrew Paquin

May 27, 2023

When I try to pipe the data (after wrangling) directly into ggplot, etc., I don't get a graph in my Markdown doc. Instead, in my environment pane, I get a file denoted with a magnifying class instead of a table icon. When I open it, I see a lise of attributes (Name, type, value). If I don't pipe the data, it works as expected. Any ideas?