在没有Internet的情况下从R中的Plotly导出PNG文件 [英] Exporting PNG files from Plotly in R without internet
问题描述
在这个问题中,从R中的Plotly导出PNG文件,我问如何将Plotly绘图导出到磁盘.
In this question, Exporting PNG files from Plotly in R I asked how to export Plotly plots to disk.
我使用了功能plotly_IMAGE
,但后来发现该功能使用了Plotly Internet服务器.
I used the function plotly_IMAGE
, but later discovered that the function uses the Plotly internet servers.
问题是,既然Plotly JavaScript是本地的,那么如何在没有Internet的情况下创建png本地文件?
The question is, now that Plotly JavaScript is local, how can I create a png local file without internet?
我尝试了此代码,但没有成功:
I tried this code, without success:
library(plotly)
png(filename = "test.png")
plot_ly(x = 1:10)
dev.off()
其想法是使其具有编程性,而无需单击图表上方的导出按钮.
The idea is to make it programaticaly, without click on export button over the chart.
推荐答案
他们已经在plotly
程序包中添加了新的export
函数.但据我所知,它的作用与@MLavoie的答案所建议的相同.用法:
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")
这篇关于在没有Internet的情况下从R中的Plotly导出PNG文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!