是否可以使用r在networkD3::forceNetwork
产生的图形上显示边缘权重?
答案 0 :(得分:0)
Value
的{{1}}参数是一个字符串,它设置了networkD3::forceNetwork
数据框中包含每个链接值的变量/列的名称。该值通常是边缘/链接权重。每个链接的指定变量中的值将确定每个链接的宽度,并显示边缘权重(如果该值所指)。
Links
library(networkD3)
library(tibble)
nodes <-
tribble(
~name, ~group,
"a", 1,
"b", 1,
"c", 1,
"d", 1
)
links <-
tribble(
~source, ~target, ~value,
0, 1, 1,
0, 2, 1,
0, 3, 1,
)
forceNetwork(Links = links, Nodes = nodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
Group = "group", opacity = 1)
UPDATE 2020.04.26
这是在链接上添加文本标签的一种方法,以便将鼠标悬停在链接上时显示链接权重的值。
links <-
tribble(
~source, ~target, ~value,
0, 1, 1,
0, 2, 20,
0, 3, 100,
)
forceNetwork(Links = links, Nodes = nodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
Group = "group", opacity = 1)