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.
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, .
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.
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.
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.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With