library(rtemis.draw).:rtemis.draw 0.3.0 🖌 aarch64-apple-darwin23
Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':
Axis
.:rtemis.draw 0.3.0 🖌 aarch64-apple-darwin23
Attaching package: 'rtemis.draw'
The following object is masked from 'package:graphics':
Axis
Network (graph) plots are rendered with Sigma.js, a WebGL renderer purpose-built for large graphs, rather than ECharts. rtemis.draw picks the most performant JavaScript library for each plot type, so networks use Sigma + graphology (layout and community detection) while the rest of the package continues to use ECharts. The high-level draw_network() and the low-level GraphModel classes are the R counterparts of the network renderer in rtemis.live.
Note on rendering Like the other draw_* functions, the network plot auto-detects your system’s light/dark setting and themes accordingly. Communities are detected with the Louvain algorithm and the default layout is ForceAtlas2; both run in the browser, so a graph re-lays out each time the widget is created.
The most common input is a square weight matrix — a correlation matrix is the canonical example. Entry [i, j] is the edge weight between nodes i and j; the absolute value drives edge thickness and the sign drives edge color, so a correlation matrix renders directly. Node ids come from the matrix dimnames, and each node’s size defaults to its weighted degree.
By default every non-zero edge is drawn. Use threshold to keep only the stronger associations:
Set color_by_group = TRUE to color nodes by their detected Louvain community. The resolution argument tunes the community sizes — higher values yield more, smaller communities:
Four layouts are available: "force" (ForceAtlas2, the default), "circular", "circlepack", and "random". The circular layout orders nodes around the ring by community so groups sit together:
Instead of a matrix you can pass an edge-list data frame. The source and target columns name the endpoints (the first two columns are used if those names are absent), with optional weight and sign columns:
An optional nodes data frame supplies node attributes (id/name, label, value, group). Any node referenced by an edge but missing from the table is added automatically. Set directed = TRUE for a directed graph:
The node and edge appearance is fully configurable. node_size sets the base radius (in screen pixels), edge_scale maps normalized weight to stroke width, and the *_opacity arguments control transparency. scale_by_degree (on by default) scales each node by its weighted degree; blend_edges colors each edge as the blend of its two endpoint colors instead of by sign:
Hover a node to highlight its neighborhood and read its degree (and community, when color_by_group is on).
draw_network() builds the graph and a SigmaOption render spec internally. For full control — assembling nodes and edges by hand, or constructing the render spec directly and rendering it with draw() — see the Sigma.js low-level S7 API chapter.