伙计们!我想在图表上插入图片而不是节点。我在 vis.js 引擎上使用了 visNetwork 库。在搜索答案时,我找到了文章https://datastorm-open.github.io/visNetwork/image_icon.html,但我尝试自己重复编写代码,不幸的是它没有在 Rstudio 中将节点绘制为图像。
setwd("/home/user/")
path_to_images<-"Images/"
nodes <- data.frame(id = 1:4,
shape = c("image", "circularImage"),
image = paste0(path_to_images, 1:4, ".png"),
label = "I'm an image")
edges <- data.frame(from = c(2,4,3,3), to = c(1,2,4,2))
visNetwork(nodes, edges, width = "100%") %>%
visNodes(shapeProperties = list(useBorderWithImage = TRUE)) %>%
visLayout(randomSeed = 2)
也许问题出在图像的本地路径中?等回复,谢谢!)