Show Sidebar Hide Sidebar

Get Requests in R

How to download plotly users's public graphs and data with R.

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.

library(plotly)
packageVersion('plotly')
## [1] '4.7.0.9000'

Download Plotly Graphs into R

Download Plotly figures directly into R with api_download_plot(). This takes the plot_id and the username as arguments.

For example, to download https://plot.ly/~cpsievert/559 into R, call:

library(plotly)
fig <- api_download_plot("559", "cpsievert")

Edit Downloaded Graph

Once the figure is downloaded, you can edit it like any plotly object. This will create a new figure unless you specify the same filename as the figure that you downloaded.

p <- layout(fig, title = paste("Modified on ", Sys.time()))

Adding a trace to a subplot figure

fig <- api_download_plot("6343", "chelsea_lyn")

p <- add_lines(fig, x = c(1, 2), y = c(1, 2), xaxis = "x2", yaxis = "y2")

Reference

See help("api")

Still need help?
Contact Us

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