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 supported.

Note: The SVG, EPS and PDF Formats are only available for Plotly Professional users. You can get more details on our pricing page.

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

  • use the export() function with the webshot package.

  • 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

Recent versions of the R package include an export() function, which does image export locally, but requires the webshot package:

if (!require("webshot")) install.packages("webshot")
tmpFile <- tempfile(fileext = ".png")
export(plot_ly(), file = tmpFile)

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.

Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.