|
6 | 6 | extension: .md
|
7 | 7 | format_name: markdown
|
8 | 8 | format_version: '1.3'
|
9 |
| - jupytext_version: 1.14.6 |
| 9 | + jupytext_version: 1.16.1 |
10 | 10 | kernel_info:
|
11 | 11 | name: python2
|
12 | 12 | kernelspec:
|
@@ -160,6 +160,32 @@ fig.update_layout(
|
160 | 160 | fig.show()
|
161 | 161 | ```
|
162 | 162 |
|
| 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 | + |
163 | 189 | ### Hovertemplate and customdata of Sankey diagrams
|
164 | 190 |
|
165 | 191 | 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