sigma.js for R. A powerful, full-featured R package for interactive graph visualisation.




Start with the 1) get started guide to get up to speed, then move on to 2) layouts then to 3) buttons and finally 4) dynamic graphs and you should be at ease with the core functionalities.

Features

Customisation

Easily and neatly layout and cluster nodes on your sigmajs graphs.


Layout Cluster

Dynamism

Learn how to make a temporal graph in static R markdown documents.

Dynamic Buttons

Animations

Animate the color, size, and x/y coordinates of the nodes on the canvas.

Animate

sigmajs plays hand-in-hand with Shiny, it lets you:

  • Catch how users interact with your graphs.
  • Easily apply filters.
  • Trigger events.

Have sigmajs play hand-in-hand with other htmlwidgets, such as leaflet, or DT to highlight nodes and neighbours on click.

Build sigmajs graphs from igraph objects or GEXF files in a single function call.

Install

sigmajs can be installed from Github,

# install.packages("devtools")
devtools::install_github("JohnCoene/sigmajs") # github

or Bitbucket,

# install.packages("remotes")
remotes::install_bitbucket("JohnCoene/sigmajs") # bitbucket

Example

Note that the graphs do not work in the RStudio viewer, and thus open in your default browser.

library(sigmajs)

# generate data
nodes <- sg_make_nodes(25) # 20 nodes
edges <- sg_make_edges(nodes, 50) # 50 edges

sigmajs() %>% # initialise
  sg_nodes(nodes, id, label, size) %>% # add nodes
  sg_edges(edges, id, source, target) %>% # add edges
  sg_layout() %>%  # layout
  sg_cluster() %>% # cluster
  sg_neighbours() # show node neighbours on node click


sigmajs is part of the twinetverse, a set of packages for Twitter network analysis and visualisation: it'll 1) get you started with network data and 2) walk you through from basic use cases to advanced functions.

Performances

sigmajs can handle very large graphs thanks to its support of WebGL, below we graph 10,000 nodes (and it can handle much more!). Note that the package also supports SVG.

data <- sg_make_nodes_edges(10000) # make 10,000 nodes

sigmajs("webgl") %>% # set to webgl
  sg_nodes(data$nodes, id, size) %>% 
  sg_edges(data$edges, id, source, target) %>% 
  sg_layout() %>% 
  sg_cluster() %>% 
  sg_settings(
    nodeColor = "default",
    defaultNodeColor = "#328983",
    edgeColor = "default",
    defaultEdgeColor = "#b9b9b9",
    minNodeSize = .8,
    maxNodeSize = 2,
    maxEdgeSize = .2
  )