Shimoku docs
Search…
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 shimoku.plt.sankey()
It must contain the following input variables:
data: Union[str, DataFrame, List[Dict]]
source: str
target: str
value: str
menu_path: str
order: int
And accepts the following input variables as optional:
title: Optional[str]
rows_size: Optional[int]
cols_size: Optional[int]
padding: Optional[List[int]]

Video demonstration of the Sankey diagram

Sankey diagram settings and usage.

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
}
]
shimoku.plt.sankey(
data=data_,
source='source', target='target', value='value',
menu_path='test/sankey-1',
order=0,
rows_size=2, cols_size=12,
)
The result is:
The Sankey diagram is in the default configuration.

2. Title for the diagram, changing data, size and padding

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
}
]
shimoku.plt.sankey(
data=data_,
source='source', target='target', value='value',
menu_path='test/sankey-2',
order=0,
rows_size=2, cols_size=9,
padding='0,0,0,2',
title='Chemical x Geothermal energies conversion',
)
The result is:
Note the space before the component using padding='0,0,0,2', and its size with cols_size=9 .
The chart has tooltips that appear to when you hover the mouse over the figure. Eight units of Chemical energy is converted to heat.
Changing menu_path The menu_path can be modified.
It is possible to use any number of rows.
Copy link
On this page
The method to use
Examples