Visualizations
Sankey
Everything you need to create beautiful, engaging, and interactive Sankey visualizations.
Importing PlotAPI Sankey
Let's import Sankey
from the PlotAPI package.
from plotapi import Sankey
We've already activated our license with the license activation instructions.
Data structure
Sankey expects a list
of dictionary
items, these will define the flow between a source
and a target
.
links = [
{"source":"Group A", "target":"Rank 1", "value": 1000},
{"source":"Group B", "target":"Rank 1", "value": 300},
{"source":"Group B", "target":"Rank 2", "value": 600},
{"source":"Group B", "target":"Rank 3", "value": 400},
{"source":"Rank 1", "target":"Club A", "value": 700},
{"source":"Rank 1", "target":"Club B", "value": 400},
{"source":"Rank 1", "target":"Club C", "value": 200},
{"source":"Rank 2", "target":"Club B", "value": 200},
{"source":"Rank 2", "target":"Club C", "value": 400},
{"source":"Rank 3", "target":"Withdrawn", "value": 400},
{"source":"Club A", "target":"The Most Amazing Prize", "value": 500},
]
We can add many source
' and target
pairings in any arrangement.
Default visualization
Creating our first Sankey Diagram is as easy as calling PlotAPI with our one input.
Be sure to interact with the visualisation to see what the default settings can do!
Sankey(links).show()
Here we can see the default behaviour of PlotAPI Sankey. This includes:
- Horizontal node labels at the shallowest and deepest depths of our diagram, with vertical labels in-between.
- An arrangement of nodes that are left aligned.
- Text-wrapping, e.g. "The Most Amazing Prize" as seen above.
- Links labelled with their quantity.
- Node and Link tooltips.
- Animations when hovering over a node.