-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Description
- We need to define both x and y or nothing will work allow provision of X coordinates only for Sankey charts #1732
- We cannot maintain the original position of a node (in R one could just add NA to that vector position)
- x and/or y should not be equal exactly to 0
Consider example below
# example from <https://plotly.com/python/sankey-diagram/>
import plotly.graph_objects as go
fig = go.Figure(data=[go.Sankey(
arrangement = "perpendicular",
node = dict(
pad = 15,
thickness = 20,
line = dict(color = "black", width = 0.5),
label = ["A1", "A2", "B1", "B2", "C1", "C2"],
color = "blue",
),
link = dict(
source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A1, B1, ...
target = [2, 3, 3, 4, 4, 5],
value = [8, 4, 2, 8, 4, 2]
))])
fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
fig.show()
Now we want to put A2, B2, C2 before A1,B1,C1 on Y axis:
fig.data[0].node.x = [0., 0., 0.5, 0.5, 1, 1]
fig.data[0].node.y = [1, 0.5, 1, 0.5, 1, 0.5]
fig.show()
We are able to see that A1 and A2 did not change their places. That because they have 0 in x coordinates.
It is easy to fix:
fig.data[0].node.x = [1e-09, 1e-09, 0.5, 0.5, 1, 1]
We are not reloading Ys, just fixing Xs is enough.
Probably plotly.js problem on visualization, but plotly.python problem for letting this.
If we will do something like fig.data[0].node.x = [np.nan, 1e-09, 0.5, 0.5, 1, 1]
, A1 will behave in the same way as if it would be a 0.
Frodnar, clementviolet, xeladsn, brooketalcott, alexandre-a-denis and 3 more
Metadata
Metadata
Assignees
Labels
No labels