R-networkD3-forceNetwork-节点形状

时间:2018-07-14 06:13:04

标签: r shiny networkd3

有没有一种方法可以根据nodeList中的列来更改节点形状,以便根据行值而不是默认圆具有不同的节点形状[rect,sqr,tri]。

文档中的MWE:

i = number of times

1 个答案:

答案 0 :(得分:0)

可以使用visNetwork包定义节点形状:

library(visNetwork)
data(MisLinks, package="networkD3")
names(MisLinks) <- c("from","to","value")

data(MisNodes, package="networkD3")
MisNodes$id <- 0:(nrow(MisNodes)-1)

# Set of available node shapes 
shapes <- c("square", "triangle", "box", "circle", "dot", "star",
            "ellipse", "database", "text", "diamond")
# Define a column of node shapes
set.seed(1)
MisNodes$shape <- sample(shapes, nrow(MisNodes), replace=T)

visNetwork(nodes=MisNodes, edges=MisLinks)

enter image description here