# 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 <a href="#the-method-to-use" id="the-method-to-use"></a>

The method is `s.plt.sankey()`

It must contain the following input variables:

```python
order: int, 
sources: str,
targets: str, 
values: str, 
data: List[Dict],
```

And accepts the following input variables as optional:

```python
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 <a href="#video-demonstration-of-the-sankey-diagram" id="video-demonstration-of-the-sankey-diagram"></a>

{% embed url="<https://www.loom.com/share/eb639b5b547a49b3a56d0a07960046a6>" %}
Sankey diagram settings and usage.
{% endembed %}

## Examples <a href="#examples" id="examples"></a>

### 1. Default Configuration <a href="#id-1.-default-configuration" id="id-1.-default-configuration"></a>

```python
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,
)
```

![The Sankey diagram is in the default configuration. ](https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FO13tWQ1ji2ERaP924V1u%2FSankey.png?alt=media\&token=0f9d6e30-6700-43c1-9b6c-0a8a63d8769b)

### 2. Customization And Context

```python
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',
)
```

![Note the space before the component using padding='0,0,0,2', and its size with cols\_size=9 .](https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FyODkpfVs96Tx1wAcmde7%2FSankey%20Configured.png?alt=media\&token=8ac9c3a5-54eb-4652-80aa-a11dc8aaeee2)

{% hint style="info" %}

### Featured Content

[changing-the-menu-path](https://docs.shimoku.com/dev/building-web-app/menu/changing-the-menu-path "mention")\
The `menu_path` can be modified.<br>

[using-the-grid](https://docs.shimoku.com/dev/building-web-app/grid/using-the-grid "mention")

It is possible to use any number of rows.
{% endhint %}
