【问题标题】:How to customize parallel categories diagram colors with plotly ? Python edition如何使用 plotly 自定义平行类别图颜色? Python版
【发布时间】:2020-09-28 17:26:00
【问题描述】:

我正在尝试从 Plotly 执行全彩色自定义并行类别图,但我做不到。有关该主题的文档完全是空的:https://plotly.github.io/plotly.py-docs/generated/plotly.graph_objects.parcats.line.colorbar.html,我没有找到示例。

I currently have this

And this is what I want (thank you Paint)

3 列,1 列只有一个类别(此处为“Base”),2 列有 2 个类别(此处为“10”和“15”)

提前谢谢你

【问题讨论】:

标签: python plotly-python


【解决方案1】:

从文档here 中的示例和go.Sankey.link? 的输出(如果您在jupyter 中),您可以检查是否可以使用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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-06
    • 2021-12-28
    相关资源
    最近更新 更多