用R语法导出Plotly

问题描述 投票:1回答:1

所以我有很多情节热图,我需要导出为.png格式。我搜索并找到了export功能。但是当使用它时会出现关于webshot的错误。

这是我正在导出的那种情节的一个例子(我有1111个这样的情节):

p <- plot_ly(z = volcano, type = "heatmap")

当我尝试export(p, file = "plot11.png")命令时,我收到错误:

Could not load file:///datatwo/13483885$/GCA%20Capstone/plotly28b83ffb3228.html
Error in webshot::webshot(f, file, ...) :
webshot.js returned failure value: 1

我该怎么做才能解决这个问题呢?

r export plotly
1个回答
0
投票

processx包可以做到,

if (!require("processx")) install.packages("processx")
orca(p, "plot11.png") ##orca is the replace of export function

如果你有plot_ly帐户,你可以轻松导出

Sys.setenv("plotly_username" = "YOUR USER NAME")
Sys.setenv("plotly_api_key" = "YOUR API KEY")
plotly_IMAGE(p, format = "png", out_file = "output.png")

sample ref link

© www.soinside.com 2019 - 2024. All rights reserved.