Working With Chart Studio Graphs in R
How to download Chart Studio users' public graphs and data into an R session.
Plotly is known for its graphing libraries, but it's also a broader ecosystem for building interactive data apps, AI data analysis tools, and deploying and hosting Dash apps. Explore the full set of tools and platforms designed to help turn data into action. Discover Plotly.
Note: We are retiring documentation for R, MATLAB, Julia, and F#. Learn more about this change here.
Download Chart Studio Graphs Into R Sessions
Download Chart Studio figures directly into your R session with the api_download_plot() function. This takes the plot_id of the Chart Studio plot and the username of the plot's creator as arguments.
For example, to download https://plotly.com/~cpsievert/559 into R, call:
library(plotly)
fig <- api_download_plot("559", "cpsievert")
fig
<!--htmlpreserve--> <!--/html_preserve-->
Update The Layout on A Downloaded Graph
Once the figure is downloaded from Chart Studio into your R session, you can update its layout just like you would any other figure you create with the plotly R package.
Note: If you were to re-upload this figure to Chart Studio, a new figure would be created unless you specify the same filename as the figure that you downloaded. In that case, the existing figure will be overwritten.
p <- layout(fig, title = paste("Modified on ", Sys.time()))
p
<!--htmlpreserve--> <!--/html_preserve-->
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")
p
<!--htmlpreserve--> <!--/html_preserve-->
Reference
See the documentation for getting started with Chart Studio in R.