question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve default node padding on Sankey

See original GitHub issue

Generating 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: bokeh_plot 2

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:closed
  • Created 5 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
odoublewencommented, May 14, 2019

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”?
bokeh_plot

Here’s an even simpler example:

nodes = ["node0","node1","node2", "node3", "node4"]
nodes = hv.Dataset(enumerate(nodes), 'index', 'label')
edges = [(0,1, 100),
         (1,2, 90),
        (1,3, 10),
        (3,4,10)]
reads = hv.Sankey((edges, nodes), ['From', 'To'])
reads.opts(opts.Sankey(labels='label', node_padding=10, label_position='right', width=900, height=300, cmap='Set1',
            edge_color=dim('To').str(), node_color=dim('index').str()))

Why does node3 have to be plotted inside of the edge connecting node1 and node2?

bokeh_plot (2)

(edit: to fixed the node labels in my example)

1reaction
philippjfrcommented, Feb 21, 2019

For example here is some synthetic data

node_padding=10

screen shot 2019-02-21 at 3 49 28 am

node_padding=2

screen shot 2019-02-21 at 3 49 14 am

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found