Shows how quantities move between stages. Nodes are drawn as bars at each stage and flows as curved ribbons whose thickness is the value.
geom_sankey(
mapping = NULL,
data = NULL,
alpha = NULL,
node_width = NULL,
label = TRUE
)
geom_alluvial(
mapping = NULL,
data = NULL,
alpha = NULL,
node_width = NULL,
label = TRUE
)A Layer to add with +.
The layout (node positions, ribbon paths) is computed from scratch: nodes are stacked within their stage in decreasing size, and ribbons leave and enter nodes in the same order, which is what keeps the crossings readable.
d <- data.frame(
from = c("Visited", "Visited", "Signed up", "Signed up"),
to = c("Signed up", "Left", "Purchased", "Churned"),
n = c(400, 600, 150, 250)
)
ggnext(d, aes(x = from, xend = to, y = n)) +
geom_sankey() +
theme_void()
#> <ggnext plot>
#> data: 4 x 3
#> aes: x = from, xend = to, y = n
#> layers: 1
#> coord: cartesian
#> mode: static