A pick of the best R packages for interactive plot and visualisation (1/2)

Plotly example
Plotly example

When it comes to presenting results to a non-technical audience, a good visualization worth hundreds of words. R comes with great abilities in data visualization, should the visualization be static, interactive and even far more complicated than a ggplot.
I am a huge fan of interactive visualization built in D3.js and other JavaScript libraries since they bring the interaction between the users and the data to a new level. So here is a list of my favorites R package for interactive data visualization.

1. Classical and yet interactive visualization: How to build interactive line charts, bar plots, … ?

Sometimes you need your bar chart or your scatter plot to be interactive. I am using three main libraries to do this:


Plotly is a javascript and D3js library with an R API. The API is really easy to use since it is really close to the ggplot syntax. Even better, you can just pass a ggplot as an argument to the ggplotly function to make it interactive! This is probably the easiest package to start with interactive plots.
Plotly is an open source package so you can use it for free. However, when you have a lot of points to plot this visualization can be laggy.


Plotly example

Output of the code above

Version:  4.7.0 ( 2017-05-28)
Package License: MIT
plotly.js License: MIT


Highcharter is an R package for the highcharts.js library which is able to display most of the plot you may want to plot. To my mind, it offers more advanced tooltips option and customization if you know some Javascript. So the library is a good candidate when Plotly is not powerful enough.For instance, with Highcharts, you can create drill downs, zooms and multiple levels pie charts with ease. Highcharter also comes with the Highstocks library to plot financial data as Candlestick and Open-high-low-close chart.
The main drawbacks of the package come from the licensing. Since Highcharts.js is not free for commercial use, you can not use highcharter if you don’t have a license.

Version: 0.5.0 ( 2017-01-17)
Package License: MIT
highchart.js License:
– Free for personnal or non-profil use
– Starting from 1495$ for commercial and governamental use.


Dygraphs is to plot time series and financial data and is based on the dygraph javascript library. This is an easy way to plot xts and xts-like objects in interactive charts and candlesticks plot. It offers an easy way to synchronize and zoom on the time series and has the huge advantages of being relatively responsive. It’s a must have to plot time-series even from big datasets.

An example of Dygraph from RStudio

Version: ( 2017-01-04 )
Package License: MIT
Dygraphs.js License: MIT


Ggiraph is adding interactive geom to ggplot to add tooltips and onclick actions to classic ggplot. Since the syntax is the ggplot one, the package is very easy to use. The example below shows how easy it is to add a basic tooltip.

ggiraph(code = print(gg))

Version: 0.4.0 ( 2017-06-24)
Package License: GPL-3
D3.js License: MIT

Other libraries for interactive plots:

Here are other libraries I haven’t used extensively.So if you have advanced feedback on these, feel free to share.

  • rBokeh, a wrapper for the Bokeh.js library.
  • chart.js, a wrapper for the Chart.js library
  • rAmChart, a wrapper for the amChart.js library, nice since it makes some specific plots easier to create (such as winrose, radarchart or funnel).
  • ggVis, from the ggplot2 team, it’s like an interactive ggplot based on Vega.
  • rChart, which is a wrapper for several .js libraries such as Morris, polyChart, highchart, NVD3, xchart, and Rickshaw.

Limitations of interactive plots:

Even though I am a fan of interactive plotting libraries, they tennds to struggle when you have a lot of points. Since the purpose of the visualization is to be displayed I often just use a representative sample of the data to keep both insights and responsiveness. Out next post on interactive visualization will deal with more complex visualisations and type of data (such as sequential, hierarchical or network data).


  1. What I’m finding, as a relatively new R user is that most of the appeals for visualization are deductive- folks are showing compelling graphs, but without discussing the underlying data, and why the chosen chart was the best one for that situation.
    This becomes particularly important for the newer people, because we may not know initially how to reorganize the data we have to comport with the requirements of the chart. Moreover, it may be that the data I have might now even make sense for the chart I’m trying to create. Or what’s worse is when someone’s data is close to what’s needed, but one critical element is missing. It’s like waking up to make pancakes, and having an egg and pancake flour, but no milk.


Please enter your comment!
Please enter your name here