Three.js and R
Three.js widgets for R and shiny. The package includes
- graphjs: an interactive force directed graph widget
- scatterplot3js: a 3-d scatterplot widget similar to, but more limited than, the scatterplot3d function
- globejs: a widget that plots data and images on a 3-d globe
The widgets are easy to use and render directly in RStudio, in R markdown, in Shiny applications, and from command-line R via a web browser. They produce high-quality interactive visualizations with just a few lines of R code.
Visualizations optionally use accelerated WebGL graphics, falling back to non-accelerated graphics for systems without WebGL when possible.
See http://threejs.org for details on three.js.
See http://bwlewis.github.io/rthreejs for an example.
This project is based on the htmlwidgets package. See https://github.com/ramnathv/htmlwidgets for details and links to amazingly cool visualization widgets for R.
New in version 0.3.0 (January, 2017)
The new 0.3.0 package version includes major changes. The
function generally works as before but with more capabilities. The
function is very different with a new API more closely tied to the igraph
The threejs package now depends on igrah. Why igraph?
- If you're doing serious network analysis, you're probably already using igraph (or you should be).
See https://bwlewis.github.io/rthreejs/animation/animation.html and https://bwlewis.github.io/rthreejs/advanced/advanced.html for short tutorials on the new graph animation capabilities.
Performance is generally much improved using extensive buffering and custom WebGL shaders where needed. See https://bwlewis.github.io/rthreejs/ego/index.html for an example.
What else is new in version 0.3.0
scatterplot3js() function was substantially improved and updated.
- The new
pchoption supports many point styles with size control.
- Interactive rotation and zooming are greatly improved and panning is now supported: press and hold the right mouse button (or touch equivalent) and move the mouse to pan.
- Mouse over labels are supported in WebGL renderings.
- Lines are supported too.
graphjs() function is completely new.
- Greater variety of WebGL vertex rendering ("pch") options, including spheres and much higher-performance options for large graphs.
- Graph layout is now external; for instance use one of the many superb igraph package graph layout options.
- Basic graph animation is supported.
Use the devtools package to install threejs directly from GitHub on any R platform (Mac, Windows, Linux, ...). You'll need the 'devtools' package.
if(!require("devtools")) install.packages("devtools") devtools::install_github("bwlewis/rthreejs")
?scatterplot3d for more examples and detailed help.
z <- seq(-10, 10, 0.1) x <- cos(z) y <- sin(z) scatterplot3js(x, y, z, color=rainbow(length(z)))
For detailed help on the widgets and additional examples, see