Visualizations Sankey
Flat link colors
PlotAPI Sankey uses gradients to colour the links by default. This can be changed to use flat colors instead.
Sample data
Let's import PlotAPI and load our sample data.
from plotapi import Sankey
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},
]
Demonstration
Link colour is controlled by the link_color_mode
parameter which is set to "gradient"
by default. The other options for link_color_mode
are "source"
which uses the source node's colour, or "target"
which uses the target node's colour.
Flat colors by target
Sankey(links, link_color_mode="target").show()
Flat colors by source
Sankey(links, link_color_mode="source").show()