Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
More complex Sankey diagram with colored links - setting the link color in one line, add the comment why 'magenta' is changed to its rgba value.

Co-Authored-By: Emmanuelle Gouillart <[email protected]>
  • Loading branch information
SylwiaOliwia2 and emmanuelle authored Mar 27, 2020
1 parent 7cc8fba commit aa79608
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/python/sankey-diagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ data = json.loads(response.read())

# override gray link colors with 'source' colors
opacity = 0.4
# change 'magenta' to its 'rgba' value to add opacity
data['data'][0]['node']['color'] = ['rgba(255,0,255, 0.8)' if color == "magenta" else color for color in data['data'][0]['node']['color']]
data['data'][0]['link']['color'] = [data['data'][0]['node']['color'][src] for src in data['data'][0]['link']['source']]
data['data'][0]['link']['color'] = [color.replace("0.8", str(opacity)) for color in data['data'][0]['link']['color']]
data['data'][0]['link']['color'] = [data['data'][0]['node']['color'][src].replace("0.8", str(opacity))
for src in data['data'][0]['link']['source']]

fig = go.Figure(data=[go.Sankey(
valueformat = ".0f",
Expand Down

0 comments on commit aa79608

Please sign in to comment.