Python: Sankey Chart

Jatin
Apr 15, 2021

--

Some History —

Sankey diagrams are helpful in visualizing the flow between source and target. The width of a link is proportional to flow volume. The chart is named after Matthew Henry Phineas Riall Sankey who introduced this flow diagram in an article on Steam Engine.

The chart is useful in showing many-to-many relationships, money flow, customer journey, sales funnel, etc.

Example —

In this example, using dummy data the Sankey diagram demonstrates how many people moved from location A (source) to location (B). I used Plotly to generate the Sankey Chart.

Example Chart
Example Data

Source and Target locations are encoded between 0 to 5. The first raw means 3 people moved from Source (0:San Francisco) to Target (2:New York).

Austin to Seattle link has the highest width as you can see on raw number 2, 10 people moved from 1 (Austin) to 3(Seattle).

Code & Explanation:

--

--