Is there a way to change the text alignment in Plotly Sankey diagram?
Asked Answered
P

0

7

I am trying to change the orientation of the node label to be left of the node and in the white space for better readability, similar to how the 'C' labels are aligned.

enter image description here

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()
Plantar answered 19/11, 2019 at 17:53 Comment(2)
This doesn't seem to be possible plotly.github.io/plotly.py-docs/generated/…Spectacular
This question is similar to: How to Specify Node Label Position for Sankey Diagram in Plotly. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.Leontine

© 2022 - 2024 — McMap. All rights reserved.