I would like to be able to specify a maximum length for Sankey plot links. My use case is the following : using a Plotly slider, I dynamically remove/add links. In my plot, the number of links ranges from very few links (e.g. 3) too many links (e.g. 100). The issue is that the links always take up the entire height of the plot, which results in very large/thick links when there's only a few of them.
Below is a simple example of this issue, when I remove one of the two links, the remaining link doubles in size. In my use case, it makes the plot not readable anymore.
When I remove a link, I would like to be able to set a with/thickness limit for the remaining links so that it doesn't take up the entire height of the plot.
I made a codepen to replicate both Sankeys above.
var link3Nodes ={
source: [0, 1],
target: [2, 2],
value: [1, 1]
}
var link2Nodes ={
source: [0],
target: [2],
value: [1]
}
var data = {
type: "sankey",
orientation: "h",
node: {
pad: 15,
thickness: 30,
line: {
color: "black",
width: 0.5
},
label: ["A1", "A2", "B"],
color: ["blue", "blue", "blue"]
},
link: link3Nodes,
// Uncomment the line below to remove one node and see a single big link.
// I wish I could set a limit for the links width/thickness
// link: link2Nodes
}
var data = [data]
var layout = {
title: "Basic Sankey",
paper_bgcolor:'#ccffcc',
font: {
size: 10
}
}
Plotly.react('myDiv', data, layout)
I tried to play around with most of the Sankey plot parameters, but unfortunately I was not able to find the relevant one if it exists.
Any help is greatly appreciated :D Thanks !
P.S: I think reducing the height of the plot is not really a solution since I want my plot controls (slider, buttons) to be fixed. One way would be to increase margins but it's very inconvenient and not robust.