Skip to contents

Creates a Sankey diagram showing directed flows between nodes. Requires the ggsankey package. Data should contain x, next_x, node, and next_node columns as generated by ggsankey::make_long.

Usage

mark_sankey(
  plot,
  mapping = NULL,
  data = NULL,
  position = NULL,
  ...,
  node_colour = "grey30",
  flow_alpha = 0.5,
  rasterize = FALSE,
  rasterize_dpi = 300,
  rasterize_dev = "cairo"
)

Arguments

plot

A plotit object

mapping

Optional new aesthetics. The default expects x, next_x, node, next_node, and optionally value.

data

Optional data for this layer

position

Position adjustment (rarely used for Sankey).

...

Other arguments passed to geom_sankey

node_colour

Colour for node rectangles (default "grey30").

flow_alpha

Alpha transparency for flow ribbons (default 0.5).

rasterize

If TRUE, rasterize via ggrastr::rasterise().

rasterize_dpi

DPI for rasterization (default 300).

rasterize_dev

Graphics device for rasterization (default "cairo").

Value

Modified plotit object

References

AntV G2: Sankey (graphlib)

Examples

if (FALSE) { # \dontrun{
if (requireNamespace("ggsankey", quietly = TRUE)) {
  df <- ggsankey::make_long(ggplot2::diamonds, cut, color)
  plotit(df, encode(x = x, next_x = next_x, node = node,
                    next_node = next_node, value = value)) |>
    mark_sankey()
}
} # }