我是Rstudio的新手,刚刚使用networkD3
包中的simpleNetwork绘制了网络图。我正在为博士论文将输出保存为PDF / JPEG / TIFF格式,但是,大多数建议是将其保存在网站(.html)上。
我的代码如下:
simpleNetwork(data, Source = 1, Target = 2, height = NULL, width = NULL,
linkDistance = 120, charge = -40, fontSize = 12, fontFamily = "serif",
linkColour = "grey", nodeColour = "black", opacity = 1.0, zoom = F)
一切正常运行,但是我无法将输出另存为PDF / JPEG / TIFF。
有什么办法可以将其保存为图片或pdf格式?
答案 0 :(得分:0)
答案 1 :(得分:0)
这是我过去使用'htmlwidgets'和'webshot'软件包所做的事情:
g <- simpleNetwork(data, Source = 1, Target = 2, height = NULL, width = NULL,
linkDistance = 120, charge = -40, fontSize = 12, fontFamily = "serif",
linkColour = "grey", nodeColour = "black", opacity = 1.0, zoom = F)
require(htmlwidgets)
saveWidget(g, file="name_of_your_file.html")
require(webshot)
webshot("file:///C:/Users/.../name_of_your_file.html", "name_of_your_pdf.pdf")