Skip to content

Commit 2011af8

Browse files
committed
add hover link example
1 parent 94b8eac commit 2011af8

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

doc/python/sankey-diagram.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.6
9+
jupytext_version: 1.16.1
1010
kernel_info:
1111
name: python2
1212
kernelspec:
@@ -160,6 +160,32 @@ fig.update_layout(
160160
fig.show()
161161
```
162162

163+
### Link Hover Color
164+
165+
Set `link.hovercolor` to change the colors of links on hover. `link.hovercolor` accepts either one color, specified as a string, that will apply to all links, or a list of colors to specify different colors for each link. Here, we use a list to specify a different color for each link:
166+
167+
```python
168+
import plotly.graph_objects as go
169+
170+
fig = go.Figure(data=[go.Sankey(
171+
node = dict(
172+
pad = 15,
173+
thickness = 20,
174+
line = dict(color = "black", width = 0.5),
175+
label = ["A1", "A2", "B1", "B2", "C1", "C2"],
176+
color = "blue"
177+
),
178+
link = dict(
179+
source = [0, 1, 0, 2, 3, 3],
180+
target = [2, 3, 3, 4, 4, 5],
181+
value = [8, 4, 2, 8, 4, 2],
182+
hovercolor=["midnightblue", "lightskyblue", "gold", "mediumturquoise", "lightgreen", "cyan"],
183+
))])
184+
185+
fig.update_layout(title_text="Basic Sankey Diagram", font_size=10)
186+
fig.show()
187+
```
188+
163189
### Hovertemplate and customdata of Sankey diagrams
164190

165191
Links and nodes have their own hovertemplate, in which link- or node-specific attributes can be displayed. To add more data to links and nodes, it is possible to use the `customdata` attribute of `link` and `nodes`, as in the following example. For more information about hovertemplate and customdata, please see the [tutorial on hover text](/python/hover-text-and-formatting/).

0 commit comments

Comments
 (0)