我正在尝试使用 visNetwork 包在 r 中制作网络图。我在尝试使我的节点标签与节点大小成比例时遇到问题。我知道节点大小由size
. nodes
但是标签大小呢?
一个额外的问题。做什么idToLabel
?我试图将其设为 TRUE 或 FALSE,网络图没有区别。
非常感谢。
这是示例代码。
library(visNetwork)
nodes <- data.frame(id = 1:10,
label = paste("Node", 1:10), # labels
group = c("GrA", "GrB"), # groups
value = 1:10, # size
title = paste0("<p><b>", 1:10,"</b><br>Node !</p>"), # tooltip
color = c("darkred", "grey", "orange", "darkblue", "purple"),# color
shadow = c(FALSE, TRUE, FALSE, TRUE, TRUE)) # shadow
edges <- data.frame(from = sample(1:10,8), to = sample(1:10, 8),
label = paste("Edge", 1:8), # labels
length = c(100,500), # length
arrows = c("to", "from", "middle", "middle;to"), # arrows
dashes = c(TRUE, FALSE), # dashes
title = paste("Edge", 1:8), # tooltip
smooth = c(FALSE, TRUE), # smooth
shadow = c(FALSE, TRUE, FALSE, TRUE)) # shadow
visNetwork(nodes, edges, physics=T, idToLabel=T)