Skip to content

Sankey arrows example #3855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 31, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions doc/python/sankey-diagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ jupyter:
text_representation:
extension: .md
format_name: markdown
format_version: '1.2'
jupytext_version: 1.6.0
format_version: '1.3'
jupytext_version: 1.14.1
kernel_info:
name: python2
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
language_info:
Expand All @@ -22,7 +22,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.7.6
version: 3.7.0
plotly:
description: How to make Sankey Diagrams in Python with Plotly.
display_as: basic
Expand Down Expand Up @@ -210,6 +210,33 @@ fig = go.Figure(go.Sankey(
fig.show()
```

### Sankey Diagram with Arrow Links

*New in 5.10*

Create a Sankey diagram with arrow links by setting the `arrowlen` attribute of `link`:

```python
import plotly.graph_objects as go

fig = go.Figure(go.Sankey(
arrangement = "snap",
node = dict(
label = ["A", "B", "C", "D", "E", "F"],
x = [0.2, 0.1, 0.5, 0.7, 0.3, 0.5],
y = [0.7, 0.5, 0.2, 0.4, 0.2, 0.3],
pad = 10
),
link = dict(
arrowlen = 15,
source = [0, 0, 1, 2, 5, 4, 3, 5],
target = [5, 3, 4, 3, 0, 2, 2, 3],
value = [1, 2, 1, 1, 1, 1, 1, 2]
)))

fig.show()
```

### Reference

See [https://plotly.com/python/reference/sankey](https://plotly.com/python/reference/sankey/) for more information and options!