我使用visNetwork来可视化我的网络。下面是代码(从visNetwork cran页面借来的)。 我的问题是:
library(igraph)
library(visNetwork)
nodes <- data.frame(id = 1:10,
label = paste("Node", 1:10),
group = c("GrA", "GrB"),
value = 1:10,
shape = c("square", "triangle", "box", "circle", "dot", "star",
"ellipse", "database", "text", "diamond"),
title = paste0("<p><b>", 1:10,"</b><br>", paste("Node", 1:10),"</p>"),
color = c("darkred", "grey", "orange", "darkblue", "purple"),
shadow = c(FALSE, TRUE, FALSE, TRUE, TRUE))
edges <- data.frame(from = sample(1:10, 8), to = sample(1:10, 8),
label = paste("Edge", 1:8),
length = c(100,500),
arrows = c("to", "from", "middle", "middle;to"),
dashes = c(TRUE, FALSE),
title = paste("Edge", 1:8),
smooth = c(FALSE, TRUE),
shadow = c(FALSE, TRUE, FALSE, TRUE))
g <- graph_from_data_frame(d = edges, vertices = nodes)
visIgraph(g)
答案 0 :(得分:0)
您可以使用 font.size
参数完成 1.(见下文)。关于 2. 和 3.,visNodes
的 title
文档阅读
默认为未定义。用户悬停时显示的标题 节点。标题可以是 HTML 元素或包含的字符串 纯文本或 HTML。
我想您可以通过调整 title
中的 html 来实现您在 3 中的愿望,就像我在下面所做的那样。
nodes <- data.frame(id = 1:10,
label = paste("Node", 1:10),
group = c("GrA", "GrB"),
value = 1:10,
shape = c("square", "triangle", "box", "circle", "dot", "star",
"ellipse", "database", "text", "diamond"),
title = paste0("<p><b style='font-size: 40px'>", 1:10,"</b><br>", paste("Node", 1:10),"</p>"),
color = c("darkred", "grey", "orange", "darkblue", "purple"),
shadow = c(FALSE, TRUE, FALSE, TRUE, TRUE),
font.size = c(0, 0, 0, 0, 0))
edges <- data.frame(from = sample(1:10, 8), to = sample(1:10, 8),
label = paste("Edge", 1:8),
length = c(100,500),
arrows = c("to", "from", "middle", "middle;to"),
dashes = c(TRUE, FALSE),
title = paste("Edge", 1:8),
smooth = c(FALSE, TRUE),
shadow = c(FALSE, TRUE, FALSE, TRUE),
font.size = c(0, 0, 0, 0))