Learn R Programming

r3js

This is the project directory for the r3js, a package to provide R and javascript functions to allow WebGL-based 3D plotting in R using the three.js javascript library. Simple interactivity through roll-over highlighting and toggle buttons is also supported.

Plots are built as html widgets, using the RStudio viewer panel to display the plots interactively. Plots can also be exported using the functions provided in the htmlwidgets package.

Installation

You can install tthe latest CRAN release with:

install.packages("r3js")

Or install the latest development version from GitHub with:

# install.packages("devtools")
devtools::install_github("shwilks/r3js")

Introduction

Generally, r3js works by generating an object containing the plotting data and then continuously updating it as new features are added to the plot (similar to plotly). For a simple 3D scatterplot however, the plot3js function handles all of the plotting setup for you. Plotting syntax is intended to be similar to the base plotting functions in R, and that used in the RGL package.

Several ways to add interactivity to plots are currently supported, namely labels, highlighting on mouse roll-over, and toggle buttons.

Using the possibilities together you can create plots like the one below.

Learn more

For a basic introduction to plotting and using the different types of interactivity see the article Getting started. For a more complex example using plot element groupings to link interaction with one plot element to changes in others see the article Grouping plot elements.

Copy Link

Version

Install

install.packages('r3js')

Monthly Downloads

454

Version

0.0.2

License

AGPL-3

Maintainer

S. Wilks

Last Published

March 21st, 2023

Functions in r3js (0.0.2)

plot3js.new

Setup a new r3js plot
mtext3js

Add text to the margin of an r3js plot
points3js

Add points to a data3js object
material3js

Set material properties of an r3js object
lines3js

Add lines to a data3js object
plot3js

3D scatter / line plot
r3js-shiny

Shiny bindings for r3js
save3jsWidget

Save an r3js widget to an HTML file
segments3js

Add lines segments a 3js object
plot3js.window

Set axis limits for a data3js object
teapot

Utah Teapot
surface3js

Add a surface to an data3js object
save3js

Save an r3js plot to an HTML file
shape3js

Add a generic shape to an 3js plot
r3js

Plot a data3js object
sphere3js

Add a sphere of defined radius to a data3js object
triangle3js

Add a triangle to a data3js object
text3js

Add text to a data3js object
background3js

Set the plot background color
group3js

Start a new r3js object group
arrows3js

Add arrows to a data3js object
legend3js

Add a legend to an data3js object
box3js

Add a box to an r3js plot
axis3js

Add an axis to an r3js plot
grid3js

Add axis grids to an data3js object
lastID

Get the ID of the last object(s) added
clippingPlane3js

Create a clipping plane object
light3js

Add a light source to a data3js object