伟大的包igraph,但我努力保存情节。我拖网没有成功。这是一些示例代码,如何保存生成的图?
Test <- data.frame(
FirstName=c("Bob","Charlie","Beth","Sam"),
Age=c(23,56,41,33))
Friends <- c(1,2,1,4,2,4,3,4)
g <- graph.empty (4, directed = FALSE)
V(g)$color <- "lightblue" #Nodes$NodeColour
V(g)$label <- as.character(Test$FirstName)
g <- add.edges(g, Friends)
plot(g,
vertex.label.color="black",
vertex.shape="sphere",
vertex.label.cex = 0.5,
vertex.size=24,
layout=layout.circle)
title("Friend Network",cex.main=1,col.main="blue")
#how do you save plot as a png?
答案 0 :(得分:0)
与将图形保存为静态图像相比,我更喜欢将它们保存为 html 文件并具有交互式图形:
library(visNetwork)
library(htmlwidgets)
saveWidget(visIgraph(g), file = "test.html")
有关详细信息,请参阅 https://datastorm-open.github.io/visNetwork/igraph.html。