Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting PNG files from Plotly in R without internet

Tags:

r

plotly

r-plotly

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 discovered that the function uses the Plotly internet servers.

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.

like image 657
Murta Avatar asked Nov 30 '15 12:11

Murta


People also ask

How do you save a plotly figure in R?

The simplest method is to use the export function from the plotly package. You simply specify which graph to save (called fig in our example) and specify the file location, name, and type with the file argument. This function can save plotly graphs as . png, .

How do you save an interactive plot from plotly?

Save Your Plot Once you have your data and plot ready to go, click on SAVE on the left-hand side. Give your PLOT and DATA a filename and select the privacy setting. For more information on how sharing works, including the difference between private, public, and secret sharing, visit this page.

Is plotly for R free?

Yes. Plotly for R is free and open-source software, licensed under the MIT license. It costs nothing to install and use. You can view the source, report issues or contribute using our Github repository.

How do you share a plotly graph?

To share a plot from the Chart Studio Workspace, click 'Share' button on the left-hand side after saving the plot. The Share modal will pop-up and display a link under the 'Embed' tab. You can then copy and paste this link to your website. You have the option of embedding your plot as an HTML snippet or iframe.


1 Answers

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")
like image 176
JaKu Avatar answered Dec 04 '22 11:12

JaKu