简体   繁体   中英

How to customize parallel categories diagram colors with plotly ? Python edition

I'm trying to perform a full colored custom parallel categories diagram from Plotly but I can't. The documentation about the subject is utterly empty: https://plotly.github.io/plotly.py-docs/generated/plotly.graph_objects.parcats.line.colorbar.html and I did not find a example.

I currently have this

And this is what I want (thank you Paint)

3 Columns, 1 with only one categorie ('Base' here), 2 with 2 categories ('10' and '15' here)

Thank you in advance

From examples in documentations here and the output (if you are in jupyter) of go.Sankey.link? you could check that you can modify the color of every link using color .


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 = ["red", "green", "orange", "red", "yellow", "green"]
  ))])

fig.show()

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM