<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/introducing-joyplots/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2017/07/joyplots.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>This is a <strong>joyplot</strong>: 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.</p>
<blockquote class="twitter-tweet" data-lang="en">
<p dir="ltr" lang="en">Peak time for sports and leisure <a rel="nofollow" href="https://twitter.com/hashtag/dataviz?src=hash" target="_blank">#dataviz</a>. About time for a joyplot; might do a write-up on them. <a rel="nofollow" href="https://twitter.com/hashtag/rstats?src=hash" target="_blank">#rstats</a> code at <a rel="nofollow" href="https://t.co/Q2AgW068Wa" target="_blank">https://t.co/Q2AgW068Wa</a> <a rel="nofollow" href="https://t.co/SVT6pkB2hB" target="_blank">pic.twitter.com/SVT6pkB2hB</a></p>
<p>— Henrik Lindberg (@hnrklndbrg) <a rel="nofollow" href="https://twitter.com/hnrklndbrg/status/883675698300420098" target="_blank">July 8, 2017</a></p></blockquote>
<p></p>
<p>The name &quot;Joy Plot&quot; was apparently <a rel="nofollow" href="https://twitter.com/JennyBryan/status/856674638981550080" target="_blank">coined by Jenny Bryan</a> 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 &quot;Unknown Pleasures&quot; <a rel="nofollow" href="https://en.wikipedia.org/wiki/File:Unknown_Pleasures_Joy_Division_LP_sleeve.jpg" target="_blank">album cover</a>, which was in actuality a <a rel="nofollow" href="https://blogs.scientificamerican.com/sa-visual/pop-culture-pulsar-the-science-behind-joy-division-s-unknown-pleasures-album-cover/" target="_blank">joyplot of radio intensities</a> from the first known pulsar. The album cover reproduced the design from a <a rel="nofollow" href="https://www.scientificamerican.com/magazine/sa/1971/01-01/#article-the-nature-of-pulsars" target="_blank">1971 Scientific American article</a> about pulsars.</p>
<p>Lindberg created the chart above using a <a rel="nofollow" href="https://github.com/halhen/viz-pub/blob/master/sports-time-of-day/2_gen_chart.R" target="_blank">simple R script</a> and some <a rel="nofollow" href="http://ggplot2.org/" target="_blank">ggplot2</a> calls, but now it's even easier to create joyplots in R thanks to the <a rel="nofollow" href="https://github.com/clauswilke/ggjoy" target="_blank">ggjoy package</a> by Claus Wilke, now <a rel="nofollow" href="http://mran.microsoft.com/package/ggjoy/" target="_blank">available on CRAN</a>. The <a rel="nofollow" href="http://mran.microsoft.com/web/packages/ggjoy/vignettes/introduction.html" target="_blank">vignette provides instructions</a> on how to use the package to create your own joyplots: you can either use the <code>geom_ridgeline</code> geom to plot individual lines (useful if your data is already in density or time series format), or use <code>geom_joy</code> to calculate densities from the samples . There's also a <code>theme_joy</code> 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 <a rel="nofollow" href="http://mran.microsoft.com/web/packages/ggjoy/vignettes/gallery.html" target="_blank">this gallery</a>, and I've also included a couple of other examples below.</p>
<p>Polarization of the US House of Representative members in the Democratic and Republican parties (based on <a rel="nofollow" href="http://rpubs.com/ianrmcdonald/293304" target="_blank">code by Ian McDonald</a>):</p>
<blockquote class="twitter-tweet" data-lang="en">
<p dir="ltr" lang="en">Asymmetric polarization: The entire GOP has moved to the right, where Dems have just become slightly less moderate. (H/t <a rel="nofollow" href="https://twitter.com/ianrmcdonald" target="_blank">@ianrmcdonald</a>) <a rel="nofollow" href="https://t.co/IeIo959qRV" target="_blank">pic.twitter.com/IeIo959qRV</a></p>
<p>— G Elliott Morris<img alt="📈" src="https://s.w.org/images/core/emoji/2/72x72/1f4c8.png" class="wp-smiley"><img alt="🙂" src="https://s.w.org/images/core/emoji/2/72x72/1f642.png" class="wp-smiley"> (@gelliottmorris) <a rel="nofollow" href="https://twitter.com/gelliottmorris/status/888904322326638592" target="_blank">July 22, 2017</a></p></blockquote>
<p></p>
<p>Worker wages by industry:</p>
<blockquote class="twitter-tweet" data-lang="en">
<p dir="ltr" lang="en">The <a rel="nofollow" href="https://twitter.com/justcapital_" target="_blank">@justcapital_</a> worker wage data for this year's rankings is taking shape. <a rel="nofollow" href="https://twitter.com/hashtag/ESG?src=hash" target="_blank">#ESG</a> <a rel="nofollow" href="https://twitter.com/hashtag/rstats?src=hash" target="_blank">#rstats</a> Thank you <a rel="nofollow" href="https://twitter.com/ClausWilke" target="_blank">@ClausWilke</a> for the joyplot package <a rel="nofollow" href="https://t.co/HBRuF7mIdq" target="_blank">pic.twitter.com/HBRuF7mIdq</a></p>
<p>— Hernando Cortina (@cortinah) <a rel="nofollow" href="https://twitter.com/cortinah/status/889970303308320769" target="_blank">July 25, 2017</a></p></blockquote>
<p></p>
<p>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 <a rel="nofollow" href="https://eagereyes.org/blog/2017/joy-plots" target="_blank">consider alternatives</a> 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.</p>
<p>Github (clauswilke): <a rel="nofollow" href="https://github.com/clauswilke/ggjoy" target="_blank">ggjoy: Geoms to make joy plots using ggplot2</a></p>
<p> </p>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2017/07/joyplots.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/-_G2jrT6uJA" height="1"></a></div>