An interactive version of the Sankey ribbons in R/functions.R. It reads the same inputs as
sankey_ribbons() / sankey_ribbons_graph(), saved as CSV files.
Files
- Flow matrices: one numeric CSV per stage (rows = source nodes, columns = target nodes); adjacent
stages must share dimensions. In graph mode, one square matrix over all loc rows. Headers and row names
(as written by R's
write.csv()) are detected and used as node names.
- Node locations (loc): columns
set, node, x, y plus optional width,
label, cex, font, height, color and
merge_col. A headerless file is read like R's numeric loc matrix
(set, node, x, y [, width [, height]]).
- Strand / mid colors: color matrices shaped like the flow matrices (hex such as
#5B8CBAAA,
CSS names, R grayNN, or NA).
- Project: a
.json file exported from this app restores everything.
- Data tables: other tables open Import table…, which builds flows from wide tables (one row per
item, a column per stage), long tables (item, stage, category), link lists (source, target, value) or
crosstabs, with options for weights, missing values, node order and grouping small nodes.
Drop files anywhere, or use Open files…; file roles are detected from their contents and names
(files whose names contain “mid” are mid colors). Stage order follows file names; reorder with the arrows.
Interaction
- Hover strands or nodes for values and shares, shown in the inspector panel; click to edit them there.
- A click emphasizes the strand or node clicked (clicking it again releases it); Shift-click adds or removes
one more while keeping the rest; clicking empty space clears the emphasis.
- Drag nodes to move them (Shift: vertical only, Alt: horizontal only).
- Drag a strand up or down to reorder it within the stack at its nearer end.
- For an imported table, the strip above the plot holds a badge over each node column, with its values
below: drag a badge sideways to reorder the columns, click it (or drag it up) to hide its column, click
a value to drop or keep its rows, and drag a value up or down to move its node. The Arrange tab
hides or shows the strip.
- For data imported from a wide or long table, hovering a strand or node traces every pathway through it
and breaks them down by node and strand in the inspector; hold Ctrl/⌘ to trace one pathway, or
Alt/⌥ for one item when the table has item ids. Ordinary hover pauses above 200 pathways by default;
adjust Hover limit (pathways) in Canvas & dragging. Emphasized strands and nodes keep their
substrands traced and tabulated together while you hover others.
- The toolbar's fit-panel and fit-height buttons scale the whole drawing, including text. Fit-height
allows horizontal scrolling; the magnifier buttons zoom in and out.
- Auto-layout (toolbar) places the nodes afresh, as an import would.
- Play paths progressively fills complete recorded trajectories from left to right, keeping
completed slices visible. Pause, Reset or seek with the progress slider. With reduced motion,
Next path steps without animation. Display order is not chronology. Tables with IDs play
their records; weighted tables without IDs play grouped paths. Edits reset playback; SVG/PNG
capture its current frame.
- The patient examples are fictitious. The one-row-per-patient cohort contains 560 synthetic
records derived from the bundled grouped counts; it is an illustration, not a clinical dataset.
- The SVG and PNG buttons export the plot as shown, including any focused substrands.
- Drag any of several emphasized nodes to move them all together, or merge two or more in one column with the Merge button that appears (Ctrl/⌘+Z undoes).
- Dragging a node into a neighbour stops at a wall, or pushes it along (Canvas & dragging).
- Ctrl/⌘+Z and Ctrl/⌘+Shift+Z undo and redo; F fits the view; Esc also clears the emphasis.
Export → R bundle writes the CSVs, a loc.csv with your edits and a sankey.R
script that redraws the plot with the R functions.