Exporting PNG files from Plotly in R

前端 未结 4 1049
自闭症患者
自闭症患者 2020-12-06 05:17

How can I export a Plotly chart as a image from R using code? (Not using the export button on the chart).

For example, this code from the Plotly site, create this ch

4条回答
  •  猫巷女王i
    2020-12-06 06:02

    There is a export function which allows you to save images without the need to connect to plotly servers. You can find it in the plotly package doc:

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

    You can even change the file type of output by selecting the extension as .png, jpeg or .pdf.

    You can also save the image in html file which allows you the plotly experience like zooming or showing annotations by using htmlwidgets::saveWidget:

    p <- plot_ly(...)
    htmlwidgets::saveWidget(p, file = "image.html")
    

提交回复
热议问题