<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/make-ggplot-graphics2-interactive-with-ggiraph/"></div></div><div><a data-url="https://www.r-bloggers.com/make-ggplot-graphics2-interactive-with-ggiraph/" data-counturl="https://www.r-bloggers.com/make-ggplot-graphics2-interactive-with-ggiraph/" data-count="horizontal" data-text="Make ggplot graphics2 interactive with ggiraph" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2016/10/make-ggplot-graphics2-interactive-with-ggiraph.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>R's <a target="_blank" href="http://ggplot2.org/">ggplot2 package</a> is a well-known tool for producing beautiful static data visualizations that you can include in a printed report. But what if you want to include a ggplot2 graphic on a webpage and provide the ability for the user to interact with the data? The <a target="_blank" href="https://github.com/davidgohel/ggiraph">ggiraph package</a> by David Gohel  (available for <a target="_blank" href="https://mran.microsoft.com/package/ggiraph/">installation via CRAN</a>). WIth ggiraph, you can take an existing ggplot2 bar chart, scatterplot, boxplot, map, or many other types of chart and add one or both of the following iteractions:</p>
<ul>
<li>Display a tooltip of your choice (e.g. data values or labels) when the cursor hovers over sections of the chart</li>
<li>Perform an action (a javascript function you provide: jump to another page, for example) when the viewer clicks on an element of the chart</li>
</ul>
<p>The tweet below (from Duc Quang Nguyen, a data journalist at swissinfo.ch) shows an animation of ggiraph in action: a <a target="_blank" href="http://www.swissinfo.ch/eng/migration-series_europe-s-immigration-balance-sheet/42495760">map of the net migration rate</a> into (green) or out of (brown) regions in Europe.</p>
<blockquote data-lang="en" class="twitter-tweet">
<p dir="ltr" lang="fr">Les profils de l'immigration diffèrent largement au sein des pays européens. Décryptage en graphiques <a target="_blank" href="https://t.co/CYby19IcBS">https://t.co/CYby19IcBS</a> <a target="_blank" href="https://twitter.com/hashtag/dataviz?src=hash">#dataviz</a> <a target="_blank" href="https://twitter.com/hashtag/ddj?src=hash">#ddj</a> <a target="_blank" href="https://t.co/F9RhWDezdD">pic.twitter.com/F9RhWDezdD</a></p>
<p>— Duc Quang Nguyen (@duc_qn) <a target="_blank" href="https://twitter.com/duc_qn/status/784005794740236288">October 6, 2016</a></p></blockquote>
<p></p>
<p>You can try out other examples of interactive charts in <a target="_blank" href="https://mran.microsoft.com/web/packages/ggiraph/vignettes/custom_effects.html">this ggirpah vignette</a>. If you already have chart written in ggplot2, it's easy to make interactive: just replace the existing geom call (e.g. <span>geom_map</span>) with its ggiraph equivalent (<span>geom_map_interactive</span>) , and provide extra arguments with information about the labels and/or javascript actions. For more details on using ggiraph, check out its home on github, linked below.</p>
<p>Github (davidgohel): <a target="_blank" href="https://github.com/davidgohel/ggiraph">ggiraph</a></p>
</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/make-ggplot-graphics2-interactive-with-ggiraph/"></div></div><div><a data-url="https://www.r-bloggers.com/make-ggplot-graphics2-interactive-with-ggiraph/" data-counturl="https://www.r-bloggers.com/make-ggplot-graphics2-interactive-with-ggiraph/" data-count="vertical" data-text="Make ggplot graphics2 interactive with ggiraph" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<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/2016/10/make-ggplot-graphics2-interactive-with-ggiraph.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 title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/9IbpKxWnBjg"></a></div>