Exporting Graphs as Static Images in R
How to export R graphs as static images.
New to Plotly?
Plotly is a free and open-source graphing library for R. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
Supported File Formats
plotly R package, you can export 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
Note Orca runs entirely locally and does not require internet access. No network requests are made to the Chart Studio or any other web service when you invoke the
orca() function to export static images in your R session.
Please follow the installation instructions which can be found on Orca's GitHub Page.
Export R Graphs As Static Images Using
To use Orca to export static images of the graphs you create with the
plotly R package, you can use the built-in
orca() function in versions
4.7.900 and above.
You need to have the
processx R package installed as well.
orca() function accepts two parameters. The first is the plot to be exported and second is the filename.
For example, running the following commands in an R session would export the graph stored in
fig in a file called
library(plotly) if (!require("processx")) install.packages("processx") fig <- plot_ly(z = ~volcano) %>% add_surface() orca(fig, "surface-plot.svg")
What About Dash?
Learn about how to install Dash for R at https://dashr.plot.ly/installation.
Everywhere in this page that you see
fig, you can display the same figure in a Dash for R application by passing it to the
figure argument of the
Graph component from the built-in
dashCoreComponents package like this:
library(plotly) fig <- plot_ly() # fig <- fig %>% add_trace( ... ) # fig <- fig %>% layout( ... ) library(dash) library(dashCoreComponents) library(dashHtmlComponents) app <- Dash$new() app$layout( htmlDiv( list( dccGraph(figure=fig) ) ) ) app$run_server(debug=TRUE, dev_tools_hot_reload=FALSE)