The best way to build an interactive bubble chart from R is through the
plotly library. If you know how to make a
ggplot2 chart, you are 10 seconds away to rendering an interactive version= just call the
ggplotly() function, and you’re done.
library(ggplot2) library(plotly) library(gapminder) p <- gapminder %>% filter(year==1977) %>% ggplot( aes(gdpPercap, lifeExp, size = pop, color=continent)) + geom_point() + theme_bw() ggplotly(p)
← this chart is interactive: hover, drag, zoom, export and more.
Three options exist to build an interactive heatmap from
plotly: as described above, plotly allows to turn any heatmap made with
d3heatmap: a package that uses the same syntax as the base R heatmap() function to make interactive version.
heatmaply: the most flexible option, allowing many different kind of customization. See the code of the chart beside here.
streamgraph package allows to build interactive streamgraphs. Hover a group to highlight it, get its name and its exact value. It's also the only way to build a streamchart from R.
plotly is very handy when it comes to build interactive area chart, since its
ggplotly() function turns a
ggplot2 version interactive. On the chart beside you can:
It is possible to save an interactive chart to both
To do so, you have to rely on the
webshot packages respectively.
It is then possible to embed your viz using an
iframe of an
img tag in
Note: it is also possible to build the interactive chart in an R markdown document to have it embedded directly.
# create a dataset: data <- data_frame( from=c("A", "A", "B", "D"), to=c("B", "E", "F", "A") ) # Plot library(igraph) p <- simpleNetwork(data, height="100px", width="100px") # save the widget at .html format library(htmlwidgets) saveWidget(p, file="myFile.html") # Save at .png library(webshot) webshot::install_phantomjs() webshot("paste_your_html_here" , "output.png", delay = 0.2 , cliprect = c(440, 0, 1000, 10))
rgl package is the best tool to work in 3D from R. Here
is an illustration: a 3d scatterplot showing the relationship between
3 numerical variables.
rgl automatically builds
interactive charts. Zooming and rotating can indeed make the chart more insightful.
Trying zooming / rotating →
chorddiag package is an htmlwidget: it automatically builds interactive charts. On the chart below, hovering a group or a connection will highlight the related flow and give additional information.
circlepackeR library allows to get an interactive circular packing with several levels of hierarchy. Click on a group to zoom on it. The post describes how to use the package from different types of input dataset.
collapsibletree package is an htmlwidget: it automatically builds collapsible interactive tree diagram. On the chart below, click a node to reveal the next branch, and zoom in/out if necessary.
networkD3 package allows to build interactive network diagrams with R. On the chart below, try to hover a node and drag it to see how it works. You can also scroll to zoom in and out. Visit the corresponding post to see how to use this tool on your dataset.
dygraph package offers zooming, hovering, minimaps and much more. Try it on the example below!