networkD3包中的sankeyNetwork在大多数情况下都非常聪明地定位节点,但有时我想将节点水平放置到另一个位置。
还有其他情况,我想垂直移动边的起点。以以下屏幕截图为例:
对于节点,我想将第2列上的B3从右侧移动到第4列(从左侧)。类似地,我想将B4从第2列从右侧移动到第5列从左侧。
How to tune horizontal node position in d3 sankeyjs
,但我不知道在R中该做什么,除此之外,我没有发现任何帖子谈论更改边缘位置。
以下是可复制的数据和代码:
load(url("https://github.com/bossaround/question/raw/master/sankeyexample.RData"))
# nn is the node, ee is the edge, now create the link (ll)
ll <- inner_join(ee, nn, by = c("N1"="name")) %>%
rename(source_ID = ID) %>%
inner_join(nn, by = c("N2"="name")) %>%
rename(target_ID = ID)
# Create Sankey Plot
sankeyNetwork(
Links = ll,
Nodes = nn,
Source = "source_ID",
Target = "target_ID",
Value = "Value",
NodeID = "newname",
fontSize = 12,
nodeWidth = 40,
nodePadding = 20,
NodeGroup = "newname"
)
提前谢谢!