Sankey diagram: position of node cannot be rendered correctly
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hello people!
I am trying to make a sankey diagram with Plotly, however, the alignment of certain node cannot be rendered correctly as I set.
PS: my Plotly version is 4.10.3 and R version is 4.3.1
Here is my code:
library("plotly")
# My data base
values <- c(10,1811,530,363,271,601,681,37,46,18,109,39,3,22,74,22,10,
14,3,81,0,1,19,1807,521,363,270,601,16,36,8,46,86,1,0,0,23,
14,18,34,684,23,0,16,0,23,0,0,0,23,14,18,69,1,34,0,0,0,684,
43,643,101,6,68,43,620,101,6,19,1807,521,363,270,601,16,36,
8,46,15,1555,79,244,346,4,115,2,2,0,4,17,251,265,1,3,25,3,
16,0,8,43,105,24,2,1,1,6,0,601,0,129,196,109,14,82,124,1,
34,2,0,13,0,11)
target <- c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,
4,4,5,5,5,5,5,5,5,5,5,5,5,10,10,10,10,10,10,10,10,11,11,11,
11,11,11,11,11,6,6,6,6,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,13,13,13,
13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,15,15,
15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,9,9,9,9)
source <- c(0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,
11,11,11,6,6,6,6,6,4,4,4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8)
num_node <- c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
x_position <- c(0.05,0.05,0.2,0.35,0.35,0.35,0.65,0.8,0.8,0.9,0.45,0.45,0.45,0.999,0.999,0.999,0.999)
y_position <- c(0.45,0.6,0.55,0.15,0.45,0.6,0.75,0.85,0.55,0.99,0.6,0.6,0.6,0.3,0.3,0.3,0.3)
# Sankey diagram with Plotly
fig <- plot_ly(
type = "sankey",
arrangement = "snap",
node = list(
label = num_node,
x = x_position,
y = y_position,
pad = 15,
thickness = 15
),
link = list(
source = source,
target = target,
value = values
)
)
fig
What I would expect is that node 13, 14, 15, 16 be at the same colomn, as I set their x position to 0.999. See picture below:
However, for some reason, my node 13 would like to be in the middle of my diagram instead of the position where it should have been. See picture below:
Does anyone have some insights why the node cannot accept x and y position I set? Thank you guys very much!
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中可复现的 R 代码开始,并使用 Plotly 4.10.3 运行它,以确认 Sankey arrangement="snap" 如何处理所提供的 x 和 y 位置。调查节点 13–16 的 Sankey 渲染行为,然后验证节点 13、14、15 和 16 仍位于 x=0.999 的同一列中。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100