I've created a large animated sankey diagram with Plotly in R. At each step in the animation Plotly rescales the the height of the links, whereas the height should be constant over time. That is, a link with a constant value should always have the same height and should not be rescaled. In the example below the link between A2 and B2 should remain the same height, rather than be rescaled so that the links fill 100% of the canvas height.
https://plotly.com/r/reference/#sankey mentions ids as an option for object constancy of data points during animation. I'm not sure whether it will do the trick, as I haven't figured out how to implement it. This or any other way to achieve constant scale would be extremely helpful.
The result should look more or less like the gif. I've "cheated" here by creating dummy nodes that take the space that should otherwise be empty. This method is less feasible for the end diagram, which is more complex than the canonical energy forecast Sankey by Mike Bostock
library(plotly)
S.links <- data.frame(source = c(0,1,0,2,3,3, 0,1,0,2,3,3),
target = c(2,3,3,4,4,5, 2,3,3,4,4,5),
value = c(8,4,2,8,4,2, 16,4,2,16,4,2),
year = c("2001","2001","2001","2001","2001","2001","2002","2002","2002","2002","2002","2002"))
plot_ly(
type = "sankey",
orientation = "h",
node = list(
label = c("A1", "A2", "B1", "B2", "C1", "C2"),
color = c("blue", "blue", "blue", "blue", "blue", "blue"),
pad = 15,
thickness = 20,
line = list(
color = "black",
width = 0.5
)
),
link = S.links,
frame = ~S.links$year
)