Sankey diagram - Improving already working graph

Hi @JourneyDS welcome to the forum!

You can change the color of both links and nodes as described in this example.

You can also change the opacity of non-hovered links like in the code below so that they are hardly visible, therefore you will mostly see the links originating from a node (when hovering on a node) or a specific link (when hovering on it)

import plotly.graph_objects as go

fig = go.Figure(data=[go.Sankey(
    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, A2, B1, ...
      target = [2, 3, 3, 4, 4, 5],
      value = [8, 4, 2, 8, 4, 2],
     color='rgba(0, 255, 255, 0.05)'
  ),
)])

fig.show()

Also it’s not exactly the same chart but have you checked out parallel categories ? It could be an interesting way of visualizing your data and since lines are straight maybe the visualization would look less busy.

1 Like