Introducing Joyplots

July 26, 2017
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

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.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

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)