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 all 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
30 changes: 29 additions & 1 deletion doc/python/sankey-diagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jupyter:
kernel_info:
name: python2
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
language_info:
Expand Down Expand Up @@ -214,6 +214,34 @@ 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!