Process flows
Visualize how quantities move between stages, categories, or entities.
Plotly · Class
go.Sankey creates an interactive flow diagram in Plotly. Nodes are named with labels, while indexed links connect sources to targets and use values to control flow width.
go.Sankey constructs a Sankey trace for a Plotly figure. Define nodes with labels and links with parallel source, target, and value arrays; each link uses zero-based node indices, and its rendered width reflects the corresponding flow value.
go.Sankey(arg=None, arrangement=None, customdata=None, domain=None, hoverinfo=None, hoverlabel=None, hovertemplate=None, ids=None, link=None, meta=None, name=None, node=None, orientation=None, selectedpoints=None, stream=None, textfont=None, uid=None, uirevision=None, valueformat=None, valuesuffix=None, visible=None)A Plotly Sankey trace object suitable for inclusion in a Figure.
import plotly.graph_objects as go
fig = go.Figure(go.Sankey(
node=dict(label=["A", "B", "C"]),
link=dict(source=[0, 1], target=[1, 2], value=[8, 4])
))
fig.show()Creates a Sankey figure whose node labels identify entities and whose links connect source and target indices with widths based on their values.
Visualize how quantities move between stages, categories, or entities.
Show contributions from inputs to outputs across multiple levels.
Communicate transfers where magnitude matters as much as connectivity.
A Sankey diagram represents flow quantities between nodes. In Plotly, node labels name the nodes, while each link connects indexed source and target nodes and uses value to determine flow volume.
Follow-up: How would you encode a link from the first node to the third? Use source=[0] and target=[2], because the node references are zero-based indices into the label list.
The source and target arrays contain node indices, and the value array contains the corresponding flow quantities. The arrays are paired by position, so source[i], target[i], and value[i] describe one link.
Follow-up: What should be checked when adding links? Verify that every referenced index exists in the node labels and that the three link arrays describe the same number of flows.
Add the trace to a go.Figure and render it with fig.show(). The trace can be created directly as go.Sankey(...) inside the figure constructor.
Follow-up: How can node presentation be customized? Supply additional node attributes such as pad, thickness, line, label, or color in the node dictionary.
plotly.graph_objects.FigureSankey.nodeSankey.link