Exporting PNG files from Plotly in R without internet

后端 未结 2 1383
误落风尘
误落风尘 2021-01-12 10:42

In this question, Exporting PNG files from Plotly in R I asked how to export Plotly plots to disk.

I used the function plotly_IMAGE, but later discovere

相关标签:
2条回答
  • 2021-01-12 11:02

    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.

    0 讨论(0)
  • 2021-01-12 11:08

    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")
    
    0 讨论(0)
提交回复
热议问题