plotly / plotly/plotly.py

plotly.graph_objects.sankey.node.Line does not work with an array of color

Offen
#4,155 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

Hi everyone,
The docs says that the argument color either takes a color or an array of colors. However, when I pass an array of colors, it always shows up black instead of the specified color. Here is a code example that does the bug :

import plotly.graph_objects as go

# define the node labels and colors
node_labels = ["A", "B", "C", "D"]
node_colors = ["red", "blue", "green", "purple"]

#Array of colors for the node's line
node_line_colors = ["black", "gray", "orange", "yellow"]

# define the links between the nodes
link_source = [0, 0, 1, 1, 2, 2]
link_target = [1, 2, 2, 3, 0, 3]
link_value = [8, 4, 2, 6, 10, 12]

# create the Sankey diagram
fig = go.Figure(data=[go.Sankey(
    node=dict(
        label=node_labels,
        color=node_colors,
        line=dict(
            color=node_line_colors, # Colors I want to have for my diagram
            width=10 # Bigger to properly see that the colors aren't here
        )
    ),
    link=dict(
        source=link_source,
        target=link_target,
        value=link_value
    )
)])

fig.show()

I also tried to manually add the colors like this instead of using the constructor :
fig.data[0]['node']['line']['color'] = node_line_colors

But the node's lines still show up black instead of coloried.
Expected result :
black line for A node,
gray line for B node,
green line for C node,
purple line for D node ;

Actual result :
image

Thanks,

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie damit, das bereitgestellte go.Sankey-Beispiel auszuführen, und vergleichen Sie das dokumentierte Array-Verhalten mit den gerenderten Knotenlinien. Verfolgen Sie, wie node.line.color behandelt wird, wenn es durch den Sankey-Konstruktor übergeben wird, und überprüfen Sie anschließend, ob die vier erwarteten Farben auf den entsprechenden Knoten gerendert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.