Lays out a graph with a from-scratch Fruchterman-Reingold force
simulation (repulsion between all nodes, attraction along edges, with a
cooling schedule) and draws nodes and edges in one unified grammar —
node and edge aesthetics come from the same aes().
geom_network(
mapping = NULL,
data = NULL,
node_size = NULL,
edge_color = NULL,
edge_width = NULL,
label = TRUE,
label_size = NULL,
alpha = NULL,
iterations = 200,
seed = 1
)Standard layer overrides. Requires x (source node)
and xend (target node); optional size weights the edges.
Node radius in px.
Edge appearance.
Node labels.
Node opacity.
Force-simulation steps; more is slower but tidier.
Random seed for the initial layout, so plots reproduce.
A Layer to add with +.
d <- data.frame(
from = c("A", "A", "B", "C", "D", "E"),
to = c("B", "C", "C", "D", "E", "A")
)
ggnext(d, aes(x = from, xend = to)) + geom_network() + theme_void()
#> <ggnext plot>
#> data: 6 x 2
#> aes: x = from, xend = to
#> layers: 1
#> coord: cartesian
#> mode: static