How to set the color of Sankey diagram lines?

As shown, the line gradients according to the color of the label.


Thank you!

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]
  ))])

fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
fig.show()

Hello, Tommy. Are you using Plotly Js or Python code here?
Seems it is not possible get this type of line with gradient color with Python.
Thanks.

Doesn’t do what you want, but we have been using this code to calculate the β€œmiddle color” of two nodes:

    # calculate intermediate color from two colors
    def link_color(col1, col2):
        color = np.sqrt((col1**2 + col2**2)/2)
        return "rgba(%d, %d, %d, 0.4)" % tuple(color)