Skip to content

Commit 8d4be8b

Browse files
add link customdata and hovertemplate
1 parent bb09a1a commit 8d4be8b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

doc/python/sankey-diagram.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.2'
9-
jupytext_version: 1.3.0
9+
jupytext_version: 1.3.1
1010
kernel_info:
1111
name: python2
1212
kernelspec:
@@ -22,7 +22,7 @@ jupyter:
2222
name: python
2323
nbconvert_exporter: python
2424
pygments_lexer: ipython3
25-
version: 3.7.3
25+
version: 3.6.8
2626
plotly:
2727
description: How to make Sankey Diagrams in Python with Plotly.
2828
display_as: basic
@@ -158,13 +158,17 @@ fig = go.Figure(data=[go.Sankey(
158158
label = ["A1", "A2", "B1", "B2", "C1", "C2"],
159159
customdata = ["Long name A1", "Long name A2", "Long name B1", "Long name B2",
160160
"Long name C1", "Long name C2"],
161-
hovertemplate='%{customdata} <br> %{value} <extra></extra>',
161+
hovertemplate='Node %{customdata} has total value %{value}<extra></extra>',
162162
color = "blue"
163163
),
164164
link = dict(
165165
source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A2, B1, ...
166166
target = [2, 3, 3, 4, 4, 5],
167-
value = [8, 4, 2, 8, 4, 2]
167+
value = [8, 4, 2, 8, 4, 2],
168+
customdata = ["q","r","s","t","u","v"],
169+
hovertemplate='Link from node %{source.customdata}<br />'+
170+
'to node%{target.customdata}<br />has value %{value}'+
171+
'<br />and data %{customdata}<extra></extra>',
168172
))])
169173

170174
fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)

0 commit comments

Comments
 (0)