Show Sidebar Hide Sidebar

Static Image Export in R

How to export plotly graphs as static images in R. Plotly supports png, svg, jpg, and pdf image export.

New to Plotly?

Plotly's R library is free and open source!
Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode.
We also have a quick-reference cheatsheet (new!) to help you get started!

Version Check

Version 4 of Plotly's R package is now available!
Check out this post for more information on breaking changes and new features available in this version.

## [1] ''

Supported Formats

The common image formats: 'PNG', 'JPG/JPEG' are supported. In addition, formats like 'EPS', 'SVG' and 'PDF' are also available for user with a Personal or Professional subscription. You can get more details on our pricing page

Note: It is important to note that any figures containing WebGL traces (i.e. of type scattergl, heatmapgl, contourgl, scatter3d, surface, mesh3d, scatterpolargl, cone, streamtube, splom, or parcoords) that are exported in a vector format like SVG, EPS or PDF will include encapsulated rasters instead of vectors for some parts of the image.

To access the image in a particular format, you can either:

  • use the orca() function. Orca is Plotly's command line applications for generating static images.

  • export the image on plotly's servers using plotly_IMAGE().

  • append the format extension to the plot url. i.e. the JPG version of the plot: is available at :

Export Locally

4.7.900 and above includes the orca() function (replacing the export() function), which exports images locally, but requires the processx package:

if (!require("processx")) install.packages("processx")

p <- plot_ly(z = ~volcano) %>% add_surface()

orca(p, "surface-plot.png")

Export Using Your Plotly Account

Another option is to do image export through your plotly account.

First, you will require the development version of plotly, this can be installed using devtools::install_github("ropensci/plotly"). In addition, if you haven't already, let the R package know about your credentials.

Sys.setenv("plotly_username" = "YOUR USER NAME")
Sys.setenv("plotly_api_key" = "YOUR API KEY")

This option will export the image on plotly's servers and write the content to a local file "output.png" in your working directory.

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")

Appending File Type to URL

You can also view the static version of any Plotly graph by appending .png, .pdf, .eps, or .svg to the end of the URL. For example, view the static image of at See Using Plotly with rmarkdown/knitr for a way to embed these links in rmarkdown/knitr (Rmd) files.