graphjs {threejs} | R Documentation |
Plot interactive force-directed graphs.
graphjs(edges, nodes, main = "", curvature = 0, bg = "white", fg = "black", showLabels = FALSE, attraction = 1, repulsion = 1, max_iterations = 1500, opacity = 1, stroke = TRUE, width = NULL, height = NULL)
edges |
Either a list with
Each row of the data frame identifies a graph edge. |
nodes |
Optional node (vertex) data frame with at least columns:
Each row of the data frame defines a graph node. If the |
main |
Plot title |
curvature |
Zero implies that edges are straight lines. Specify a positive number to curve the edges, useful to distinguish multiple edges in directed graphs (the z-axis of the curve depends on the sign of |
bg |
Plot background color specified similarly to the node colors described above |
fg |
Plot foreground text color |
showLabels |
If |
attraction |
Numeric value specifying attraction of connected nodes to each other, larger values indicate more attraction |
repulsion |
Numeric value specifying repulsion of all nodes to each other, larger values indicate greater repulsion |
max_iterations |
Integer value specifying the maximum number of rendering iterations before stopping |
opacity |
Node transparency, 0 <= opacity <= 1 |
stroke |
If TRUE, stroke each node with a black circle |
width |
optional widget width |
height |
optional widget height |
An htmlwidget object that is displayed using the object's show or print method.
(If you don't see your widget plot, try printing it with the print
) function.
All colors must be specified as color names like "red", "blue", etc. or as hexadecimal color values without opacity channel, for example "#FF0000", "#0a3e55" (upper or lower case hex digits are allowed).
The plot responds to the following mouse controls (touch analogs may also be supported on some systems):
scrollwheel
zoom
left-mouse button + move
rotate
right-mouse button + move
pan
mouse over
identify node by appending its label to the title
Double-click or tap on the plot to reset the view.
Basic support for plotting igraph
objects is provided by the
igraph2graphjs
function.
Original code by David Piegza: https://github.com/davidpiegza/Graph-Visualization.
The three.js project http://threejs.org.
data(LeMis) g <- graphjs(LeMis, main="Les Misérables", showLabels=TRUE) print(g) ## Not run: # The next example uses the `igraph` package. library(igraph) set.seed(1) g <- sample_islands(3, 10, 5/10, 1) i <- cluster_optimal(g) g <- set_vertex_attr(g, "color", value=c("yellow", "green", "blue")[i$membership]) print(graphjs(g)) ## End(Not run)