Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Three.js widgets for R and shiny

License

NotificationsYou must be signed in to change notification settings

bwlewis/rthreejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Three.js widgets for R and shiny. The package includes

  • graphjs: an interactive network visualization widget
  • scatterplot3js: a 3-d scatterplot widget similar to, but more limited than, the scatterplot3d function
  • globejs: a somewhat silly 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, inShiny applications, and from command-line R via a web browser. They producehigh-quality interactive visualizations with just a few lines of R code.

Visualizations optionally use accelerated WebGL graphics, falling back tonon-accelerated graphics for systems without WebGL when possible.

Seehttps://threejs.org for details on three.js.

Seehttps://bwlewis.github.io/rthreejs for R examples.

This project is based on the htmlwidgets package. Seehttp://htmlwidgets.orgfor details and links to many other visualization widgets for R.

Changes in version 0.3.4 (August, 2021)

Added a JavaScript 'program' function argument to run extra user-suppliedJavaScript initialization code, see the graphjs help for examples.

New in version 0.3.0 (June, 2017)

The new 0.3.0 package version introduces major changes. Thescatterplot3js()function generally works as before but with more capabilities. Thegraphjs()function is very different with a new API more closely tied to the igraphpackage.

The threejs package now depends on igraph. If you're doing serious networkanalysis, you're probably already using igraph (or you should be). Threejs nowuses external graph layouts (either from igraph or elsewhere). This gives muchgreater graph layout flexibility, something I was looking for, but also removesthe cute (but slow and crude) force-directed JavaScript animation previouslyused. To partially make up for that, several new graph animation andinteraction schemes are newly available.

Seehttps://bwlewis.github.io/rthreejs/animation/animation.htmlandhttps://bwlewis.github.io/rthreejs/advanced/advanced.html for short tutorials on thenew graph animation capabilities.

Performance ofgraphjs() is generally much improved using extensive bufferingand custom WebGL shaders where needed. Seehttps://bwlewis.github.io/rthreejs/ego/index.html for an example.

Summary of changes

Thescatterplot3js() function was substantially improved and updated.

  • The newpch option 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.
  • Thepoints3d() interface has changed to support pipelining.
  • Lines are supported too, seelines3d().
  • Support for crosstalk selection handles (seedemo("crosstalk", package="threejs")).
  • Set the experimentaluse.orbitcontrols=TRUE option for more CPU-efficient (but less fluid) rendering (good for laptops), also applies tographjs().

Thegraphjs() function is completely new.

  • Greater variety of WebGL vertex rendering ("pch") options, including spheresand much higher-performance options for large graphs.
  • Graph layout is now external; for instance use one of the many superbigraph package graph layout options.
  • Graph animation is supported, see the examples.
  • Interactive (click-able) graph animation is supported, seedemo(package="threejs") for examples.
  • Limited brushing is available to highlight portions of the graph, see thebrush=TRUE option.
  • Support for crosstalk selection handles.

Known issues

  • RStudio on Windows systems may not be able to render the WebGL graphics emittedby threejs. RStudio users running on Windows systems may need to use the plot"pop out" button to see visualizations in an external browser. We expect thisto be a temporary problem until the underlying graphics rendering system usedby RStudio is updated later in 2017.
  • The fallback Canvas rendering code has diverged too much from the baselineWebGL code and no longer works. We have temporarily disabled Canvasrendering with an error message. See#67for details.
  • Crosstalk filter handles are used in a non-standard and experimental way tocontrol graph animation. Don't rely on this experimental feature.

Install

Use the devtools package to install threejs directly from GitHub on anyR platform (Mac, Windows, Linux, ...). You'll need the 'devtools' package.

if(!require("devtools")) install.packages("devtools")devtools::install_github("bwlewis/rthreejs")

Examples

See?scatterplot3d for more examples and detailed help.

library(threejs)z<- seq(-10,10,0.1)x<- cos(z)y<- sin(z)scatterplot3js(x,y,z,color=rainbow(length(z)))

The following example plots an undirected graph with 4039 vertices and 88234edges from the Stanford SNAP networkrepositoryhttp://snap.stanford.edu/data/facebook_combined.txt.gz.

data(ego)graphjs(ego,bg="black")

The next example illustrates the globe widget by plotting the relativepopulation of some cities using data from the R maps package on a globe. It'sbased on the JavaScript WebGL Globe Toolkit (https://github.com/dataarts) bythe Google Creative Lab Data Arts Team.

runApp(system.file("examples/globe",package="threejs"))

For detailed help on the widgets and additional examples, see

?scatterplot3js?globejs?graphjs

Packages

No packages published

Contributors9


[8]ページ先頭

©2009-2025 Movatter.jp