在没有互联网的情况下从 R 中的 Plotly 导出 PNG 文件 [英] Exporting PNG files from Plotly in R without internet

查看:16
本文介绍了在没有互联网的情况下从 R 中的 Plotly 导出 PNG 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个问题中,Exporting PNG files from Plotly in R我问了如何将 Plotly 图导出到磁盘.

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

我使用了函数plotly_IMAGE,但后来发现该函数使用了Plotly互联网服务器.

I used the function plotly_IMAGE, but later discovered that the function uses the Plotly internet servers.

问题是,既然 Plotly JavaScript 是本地的,我如何在没有互联网的情况下创建一个 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")

这篇关于在没有互联网的情况下从 R 中的 Plotly 导出 PNG 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆