【发布时间】:2018-07-28 02:34:36
【问题描述】:
我使用plotly 包创建了一个桑基图。
据我所知,节点的默认顺序主要由值定义。但是,我希望不使用鼠标药物手动移动节点的字母顺序。
我可以用 R 更改默认顺序吗?
任何帮助将不胜感激。以下是示例代码和输出:
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))
【问题讨论】:
-
您找到解决方案了吗?如果没有,您可以考虑提供赏金以给予更多关注。
-
@Wolfgang;哦,好吧,那太糟糕了。感谢您的评论。
-
现在你可以通过
.node(x|y)github.com/plotly/plotly.js/pull/3583定义位置 -
@banderlog013 ;一百万谢谢!!!!我会发布你提到的答案。
标签: r plotly sankey-diagram