使用visNetwork包,我们如何添加边框?
library(visNetwork)
nodes <- data.frame(id = 1:3,
color.background = c("red", "blue", "green"),
color.highlight.background = c("red", NA, "red"),
shadow.size = c(5, 10, 15))
edges <- data.frame(from = c(1,2), to = c(1,3),
label = LETTERS[1:2],
font.color =c ("red", "blue"),
font.size = c(10,20))
visNetwork(nodes, edges)
我们可以设置背景颜色,但我更喜欢情节的轮廓/边框。
如果它是相关的,我在shiny中使用它,这里是一个例子:
library(shiny)
library(visNetwork)
shinyApp(
ui = fluidPage(
visNetworkOutput("vis1", height = "200px"),
visNetworkOutput("vis2", height = "200px")
),
server = function(input, output, session) {
nodes <- data.frame(id = 1:3, group = c("B", "A", "B"))
edges <- data.frame(from = c(1,2), to = c(2,3))
output$vis1 <- renderVisNetwork({
visNetwork(nodes, edges,
main = "my vis 1")
})
output$vis2 <- renderVisNetwork({
visNetwork(nodes, edges, background = "red",
main = "my vis 2, with red background")
})
})
并且想看剧情的轮廓,这里首先vis( vis1
)没有轮廓,只是透明的背景,很难分辨出边框在哪里: