Visualizations Sankey
Link opacity
The opacity of the links in the Sankey diagram can be changed. The opacity will change on mouse-over to highlight the selected connections.
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 foreground opacity
To change the foreground link colour opacity, we set link_opacity
with a number between or including
Sankey(links, link_opacity=0.75).show()
Link background opacity
To change the background link colour opacity, we set link_background_opacity
with a number between or including
Sankey(links, link_background_opacity=0.4).show()
Note
When setting link_background_opacity=1
in combination with a solid link_background_color
, it can become difficult to discern between overlapping links.