Sankey Diagram
A Sankey diagram depicts flows of matter, energy or any other quantity, where the width of each flow pictured is based on its quantity.
The Method To Use
The method is s.plt.sankey()
It must contain the following input variables:
order: int,
sources: str,
targets: str,
values: str,
data: List[Dict],
And accepts the following input variables as optional:
option_modifications: Optional[Dict]
title: Optional[str]
padding: Optional[List[int]]
rows_size: Optional[int]
cols_size: Optional[int]
Video demonstration of the Sankey diagram
Examples
1. Default Configuration
data = [
{
"source": "a",
"target": "a1",
"value": 5
},
{
"source": "a",
"target": "a2",
"value": 3
},
{
"source": "a",
"target": "b1",
"value": 8
},
{
"source": "b",
"target": "b1",
"value": 6
},
{
"source": "b1",
"target": "a1",
"value": 1
},
{
"source": "b1",
"target": "c",
"value": 2
}
]
s.plt.sankey(
data=data, order=0,
sources='source', targets='target', values='value',
rows_size=2, cols_size=12,
)

2. Customization And Context
data = [
{
"source": "Chemical energy",
"target": "light",
"value": 15
},
{
"source": "Chemical energy",
"target": "electricity",
"value": 3
},
{
"source": "Chemical energy",
"target": "heat",
"value": 8
},
{
"source": "Geothermal energy",
"target": "heat",
"value": 6
},
{
"source": "heat",
"target": "light",
"value": 1
},
{
"source": "heat",
"target": "movement",
"value": 2
}
]
s.plt.sankey(
data=data, order=0,
sources='source', targets='target', values='value',
rows_size=2, cols_size=9, padding='0,0,0,2',
title='Chemical x Geothermal energies conversion',
)

adding='0,0,0,2',
and its size with cols_size=9
.Featured Content
Changing the Menu Path
The menu_path
can be modified.
It is possible to use any number of rows.
Last updated
Was this helpful?