I created a Sankey diagram using the plotly
package.
As far as I see, the default order of nodes is mostly defined by the value. However, I want the alphabetical order without manually moving nodes with mouse drug.
Can I change the default order with R?
Any help would be greatly appreciated. Below is an example code and the outputs:
node_label <- c("x1_1", "x1_2", "x2_1", "x2_2")
link_source <- c(0, 0, 1, 1)
link_target <- c(2, 3, 2, 3)
link_value <- c(2, 5, 1, 3)
# when link_value <- c(5, 2, 1, 3), the order is changed.
plotly::plot_ly(
type = "sankey",
domain = list(x = c(0,1), y = c(0,1)),
node = list(label = node_label),
link = list(
source = link_source,
target = link_target,
value = link_value))
.node(x|y)
github.com/plotly/plotly.js/pull/3583 – Sebiferous