node positions do not work with link value zero in Sankey
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Hello,
I'm new to the plot.ly lib but I already discovered an issue.
If there is a node with:
- no links
- only links with the value of zero
the manual positioning doesn't work anymore except if you delete the relating coordinates of this node and keep the node in the list (see third example).
Below you can find a short testing code with the generated output.
working example
import plotly.graph_objects as go
data=go.Sankey(
arrangement = "freeform",
node = {
"label": ["A", "B", "C", "D", "E", "F"],
"x": [0.2, 0.1, 0.9, 0.7, 0.3, 0.9],
"y": [0.1, 0.9, 0.2, 0.1, 0.9, 0.9],
'pad':100}, # 10 Pixels
link = {
"source": [0, 0, 1, 4, 4, 3, 3],
"target": [1, 3, 4, 3, 5, 2, 5],
"value": [3, 3, 5, 4, 10, 1, 7 ]})
fig_sankey = go.Figure(data=data)
fig_sankey.show()

node with only one link with value of zero
import plotly.graph_objects as go
data=go.Sankey(
arrangement = "freeform",
node = {
"label": ["A", "B", "C", "D", "E", "F"],
"x": [0.2, 0.1, 0.9, 0.7, 0.3, 0.9],
"y": [0.1, 0.9, 0.2, 0.1, 0.9, 0.9],
'pad':100}, # 10 Pixels
link = {
"source": [0, 0, 1, 4, 4, 3, 3],
"target": [1, 3, 4, 3, 5, 2, 5],
"value": [3, 3, 5, 4, 10, 0, 7 ]})
fig_sankey = go.Figure(data=data)
fig_sankey.show()

kind of working again cause coordinates of C are deleted
import plotly.graph_objects as go
data=go.Sankey(
arrangement = "freeform",
node = {
"label": ["A", "B", "C", "D", "E", "F"],
"x": [0.2, 0.1, 0.7, 0.3, 0.9],
"y": [0.1, 0.9, 0.1, 0.9, 0.9],
'pad':100}, # 10 Pixels
link = {
"source": [0, 0, 1, 4, 4, 3, 3],
"target": [1, 3, 4, 3, 5, 2, 5],
"value": [3, 3, 5, 4, 10, 0, 7 ]})
fig_sankey = go.Figure(data=data)
fig_sankey.show()

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Python Sankey examples and comparing freeform positioning when one link has value zero. Trace the Sankey rendering path from the Python figure definition to the component that handles node positions. Done means manual coordinates remain effective for nodes with no links or only zero-valued links, with a regression test covering both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100