Exporting PNG files from Plotly in R without internet

落花浮王杯 提交于 2019-12-01 04:46:30

They've added a new export function to the plotly package. But to my knowledge it does the same thing as @MLavoie's answer suggests. Usage:

p <- plot_ly(...)
export(p, file = "test.png")

You will to need install Phantom (http://phantomjs.org/download.html) which is quite easy and you can try this:

library(plotly)
library(webshot)
library(htmlwidgets)

m <- plot_ly(x = 1:10)
saveWidget(as.widget(m), "temp.html")
webshot("temp.html", file = "test.png",
        cliprect = "viewport")

you will find temp.html and temp.png in your working directory.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!