Improve default node padding on Sankey
See original GitHub issueGenerating a Sankey diagram with many nodes results in a plot with many overlaps of nodes and crisscrossing of edges. It’s nearly impossible to interpret the data with so many overlapping nodes and crisscrossing edges.
Example:
sankey = hv.Sankey(data, kdims=['source', 'target'], vdims='value') \
.opts(width=1000, height=700, label_position='left', edge_color='target', node_color='index', cmap='tab20')
Produces the following plot:
Where data looks like:
source | target | type | value |
---|---|---|---|
B45 | C0 | 2 | 339 |
B45 | C6 | 2 | 318 |
B45 | C78 | 2 | 185 |
B45 | C52 | 2 | 179 |
B45 | C67 | 2 | 158 |
B45 | C92 | 2 | 144 |
B60 | C71 | 2 | 131 |
B45 | C65 | 2 | 122 |
B45 | C13 | 2 | 121 |
B49 | C71 | 2 | 107 |
B45 | C93 | 2 | 86 |
B45 | C9 | 2 | 83 |
B14 | C92 | 2 | 82 |
B60 | C69 | 2 | 82 |
B78 | C93 | 2 | 81 |
B30 | C91 | 2 | 75 |
B92 | C9 | 2 | 74 |
B45 | C83 | 2 | 73 |
B49 | C41 | 2 | 73 |
B80 | C45 | 2 | 73 |
B45 | C71 | 2 | 70 |
B38 | C45 | 2 | 65 |
B13 | C71 | 2 | 62 |
B45 | C60 | 2 | 61 |
B60 | C93 | 2 | 55 |
B60 | C99 | 2 | 55 |
B49 | C33 | 2 | 53 |
B45 | C34 | 2 | 52 |
B83 | C56 | 2 | 52 |
B92 | C6 | 2 | 51 |
… | … | … | … |
A5 | B77 | 1 | 48 |
A5 | B17 | 1 | 45 |
A5 | B9 | 1 | 40 |
A5 | B37 | 1 | 38 |
A5 | B68 | 1 | 38 |
A5 | B84 | 1 | 35 |
A5 | B56 | 1 | 31 |
A5 | B59 | 1 | 31 |
A5 | B74 | 1 | 30 |
A5 | B25 | 1 | 28 |
A5 | B11 | 1 | 21 |
A5 | B34 | 1 | 20 |
A5 | B61 | 1 | 20 |
A5 | B98 | 1 | 19 |
A5 | B12 | 1 | 15 |
A5 | B6 | 1 | 15 |
A5 | B33 | 1 | 14 |
A5 | B19 | 1 | 13 |
A5 | B23 | 1 | 9 |
A5 | B46 | 1 | 9 |
A5 | B44 | 1 | 7 |
A5 | B36 | 1 | 6 |
A5 | B70 | 1 | 6 |
A5 | B42 | 1 | 5 |
A5 | B53 | 1 | 3 |
A5 | B26 | 1 | 2 |
A5 | B3 | 1 | 2 |
A5 | B8 | 1 | 2 |
A5 | B15 | 1 | 1 |
A5 | B16 | 1 | 1 |
997 rows × 4 columns
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Improve default node padding on Sankey · Issue #3501 - GitHub
The Sankey layout algorithm minimizes the overlap of the edges by default, but there's only so much it can do automatically so I...
Read more >series.sankey.dataLabels.padding | highcharts API Reference
For sankey charts, data labels are visible for the nodes by default, ... To make the labels less sensitive for overlapping, the dataLabels.padding...
Read more >D3 Sankey customization - Stack Overflow
For example, if I have a d3-generated Sankey chart within a div named ... and then play with the "nodePadding" parameter in the...
Read more >Sankey Chart - NeoDash Documentation - Neo4j
Name Type Default Value
Show Legend on/off off
Enable interactivity on/off on
Relationship Property text value
Read more >Sankey Diagram | FusionCharts
Set Padding between Nodes. You can add white space between consecutive nodes to make the chart look less cluttered. It will increase the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also had this question. Seems like the code example in the Holoviews docs also offers an example of non-optimal behavior, in that nodes overlap unnecessarily with edges. I would expect the method to try to minimize not just node-node overlap but also node-edge overlap.
For example, why is the “Early Career Researcher” node superimposed on top of the edge that connects “PhD” and “Career Outside Science”?
Here’s an even simpler example:
Why does node3 have to be plotted inside of the edge connecting node1 and node2?
(edit: to fixed the node labels in my example)
For example here is some synthetic data
node_padding=10
node_padding=2