Visualizations Sankey
Layout properties
The title, width, height, margin, position, background color, and border can be changed with these layout properties.
Sample data
Let's import PlotAPI and load our sample data.
from plotapi import Sankey
links = [
{"source":"Group A", "target":"Rank 1", "value": 1002},
{"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
We can modify the width
, height
, and margin
of our diagram.
The margin
is a single float
value that is applied as an equal margin of that size.
The background_color
and border
can be changed too.
To include a diagram title, we can pass the desired string into the title
parameter.
By default a Sankey diagram is centered, but this can be disabled with center=False
.
With layout properties
Sankey(
links,
colors="turbo",
title="PlotAPI Sankey with a Title",
link_numbers=False,
width=800,
height=400,
margin=0,
center=False,
background_color="#f1f1f1",
border="#333 dashed",
).show()
Without layout properties
Sankey(links).show()