Introducing Joyplots

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This is a joyplot: a series of histograms, density plots or time series for a number of data segments, all aligned to the same horizontal scale and presented with a slight overlap.

The name “Joy Plot” was apparently coined by Jenny Bryan in April 2017, in response to one of Lindberg's earlier visualizations using this style. (The community appears to have settled on 'joyplot' since then.) The name refers to the classic 1979 Joy Division “Unknown Pleasures” album cover, which was in actuality a joyplot of radio intensities from the first known pulsar. The album cover reproduced the design from a 1971 Scientific American article about pulsars.

Lindberg created the chart above using a simple R script and some ggplot2 calls, but now it's even easier to create joyplots in R thanks to the ggjoy package by Claus Wilke, now available on CRAN. The vignette provides instructions on how to use the package to create your own joyplots: you can either use the geom_ridgeline geom to plot individual lines (useful if your data is already in density or time series format), or use geom_joy to calculate densities from the samples . There's also a theme_joy theme which eliminates the traditional ggplot grid for a cleaner result more reminiscent of the classic 1971 joyplot. You can see several examples (with code) in this gallery, and I've also included a couple of other examples below.

Polarization of the US House of Representative members in the Democratic and Republican parties (based on code by Ian McDonald):

Worker wages by industry:

As you can see from the examples above, joyplots work best when you want to compare the distributions of several subgroups, and the number of groups is large (so that a traditional panel plot would take up too much space). That said, joyplots do inevitably obscure some data due to the overlap, and you may want to consider alternatives like heat maps or even simple bar charts of means or medians. In any case, the new ggjoy package makes it easy to try them out and decide what works best for your data.

Github (clauswilke): ggjoy: Geoms to make joy plots using ggplot2


To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)