Supported File Formats
plotly R package, you can export graphs you create as static images in the
.jpeg file formats for free using the Chart Studio web service.
Currently, exporting graphs you create as static images in the
Note: It is important to be aware that R graphs containing WebGL-based traces (i.e. of type
parcoords) will include encapsulated rasters instead of vectors for some parts of the image if they are exported as static images in a vector format like
Exporting Chart Studio Charts As Static Images
To export your R graphs as static images using the Chart Studio web service, you can use the built-in
Create A Chart Studio Account And Get An API Key
To use the
plotly_IMAGE() function, you will need to have a Chart Studio account and an API key (which can be found in your Chart Studio account online settings). Learn more about getting started with Chart Studio in R.
Set Environment Variables In Your R Session
Let the R session know about your Chart Studio authorization credentials by setting environment variables using
Sys.setenv("plotly_username" = "YOUR USER NAME") Sys.setenv("plotly_api_key" = "YOUR API KEY")
Use The Development Version Of The
plotly R Package
You will also need to be using the development version of the
plotly R package in order to use the
plotly_IMAGE() function. This can be installed from GitHub using the
devtools R package by running the following command in your R session:
Export R Graph As Static Image
plotly_IMAGE() function exports your R plots as static images using the Chart Studio web service. The image will be stored in a file in the working directory of your R session.
library(plotly) p <- plot_ly(x = c(1,2,3,4), y = c(2,4,1,3), type = 'scatter', mode = 'lines') plotly_IMAGE(p, format = "png", out_file = "output.png")
Alternative Methods Of Exporting Graphs As Static Images In R
Local Image Export
As an alternative to using the Chart Studio web service to export your R graphs as static images, you can use the built-in
orca() function to export images locally.
Embed R Charts in RMarkdown Documents
See Embedding Graphs in RMarkdown to learn more about embedding R charts in RMarkdown (.Rmd) files.