You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the `plotly` R package, you can export graphs you create as static images in the `.png` and/or `.jpg`/`.jpeg` file formats for free using the [Chart Studio web service](https://chart-studio.plot.ly/create/#/).
25
25
26
-
Plotly's R library is free and open source!<br>
27
-
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
28
-
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
29
-
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
26
+
Currently, exporting graphs you create as static images in the `.eps`, `.svg`, and/or `.pdf` format is a feature that is available only to users of [Chart Studio Enterprise](https://plot.ly/online-chart-maker/).
30
27
31
-
### Version Check
28
+
**Note:** It is important to be aware that R graphs containing WebGL-based traces (i.e. of type `scattergl`, `heatmapgl`, `contourgl`, `scatter3d`, `surface`, `mesh3d`, `scatterpolargl`, `cone`, `streamtube`, `splom`, and/or `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 `.eps`, `.svg`, and/or `.pdf`.
32
29
33
-
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
34
-
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
30
+
### Exporting Chart Studio Charts As Static Images
35
31
36
-
```{r}
37
-
library(plotly)
38
-
packageVersion('plotly')
39
-
```
40
-
41
-
### Supported Formats
42
-
43
-
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] (https://plot.ly/products/cloud/)
44
-
45
-
**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.
32
+
To export your R graphs as static images using the Chart Studio web service, you can use the built-in `plotly_IMAGE()` function.
46
33
47
-
To access the image in a particular format, you can either:
34
+
#### Create A Chart Studio Account And Get An API Key
48
35
36
+
To use the `plotly_IMAGE()` function, you will need to have a [Chart Studio account](https://chart-studio.plot.ly/Auth/login/?action=signup#/) and an API key (which can be found [in your Chart Studio account online settings](https://plot.ly/settings/api)). Learn more about [getting started with Chart Studio in R](https://plot.ly/r/getting-started-with-chart-studio).
49
37
50
-
* use the `orca()` function. [Orca](https://github.com/plotly/orca) is Plotly's command line applications for generating static images.
38
+
#### Set Environment Variables In Your R Session
51
39
52
-
* export the image on plotly's servers using `plotly_IMAGE()`.
53
-
54
-
* append the format extension to the plot url. i.e. the JPG version of the plot: https://plot.ly/~chris/1638 is available at : https://plot.ly/~chris/1638.jpg.
55
-
56
-
### Export Locally
57
-
58
-
`4.7.900` and above includes the `orca()` function (replacing the `export()` function), which exports images locally, but requires the processx package:
40
+
Let the R session know about your Chart Studio authorization credentials by setting environment variables using [`Sys.setenv()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Sys.setenv).
59
41
60
42
```{r, eval = FALSE}
61
-
if (!require("processx")) install.packages("processx")
62
-
63
-
p <- plot_ly(z = ~volcano) %>% add_surface()
64
-
65
-
orca(p, "surface-plot.svg")
43
+
Sys.setenv("plotly_username" = "YOUR USER NAME")
44
+
Sys.setenv("plotly_api_key" = "YOUR API KEY")
66
45
```
67
46
68
-
### Export Using Your Plotly Account
69
-
70
-
Another option is to do image export through your plotly account.
47
+
#### Use The Development Version Of The `plotly` R Package
71
48
72
-
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.
49
+
You will also need to be using the development version of the `plotly` R package in order to use the `plotly_IMAGE()` function. This can be installed from GitHub using the [`devtools`](https://cran.r-project.org/web/packages/devtools/index.html)R package by running the following command in your R session:
73
50
74
-
75
-
```{r, eval = FALSE}
76
-
Sys.setenv("plotly_username" = "YOUR USER NAME")
77
-
Sys.setenv("plotly_api_key" = "YOUR API KEY")
51
+
```r
52
+
devtools::install_github("ropensci/plotly")
78
53
```
79
54
80
-
This option will export the image on plotly's servers and write the content to a local file `"output.png"` in your working directory.
55
+
#### Export R Graph As Static Image
56
+
57
+
The `plotly_IMAGE()` function exports your R plots as static images using the Chart Studio web service. The image will be stored in a file in the working directory of your R session.
### Alternative Methods Of Exporting Graphs As Static Images In R
68
+
69
+
#### Local Image Export
70
+
71
+
As an alternative to using the Chart Studio web service to export your R graphs as static images, you can [use the built-in `orca()` function](https://plot.ly/r/static-image-export) to export images locally.
72
+
73
+
#### Embed R Charts in RMarkdown Documents
91
74
92
-
You can also view the static version of any Plotly graph by appending `.png`,
93
-
`.pdf`, `.eps`, or `.svg` to the end of the URL. For example, view the static image of <https://plot.ly/~chris/1638> at <https://plot.ly/~chris/1638.png>. See [Using Plotly with rmarkdown/knitr](https://plot.ly/r/knitr/) for a way to embed these links in rmarkdown/knitr (Rmd) files.
75
+
See [Embedding Graphs in RMarkdown](https://plot.ly/r/embedding-graphs-in-rmarkdown/) to learn more about embedding R charts in RMarkdown (.Rmd) files.
description: How to export plotly graphs as static images in R. Plotly supports png,
3
-
svg, jpg, and pdf image export.
2
+
description: How to export R graphs as static images using Chart Studio.
4
3
display_as: chart_studio
5
4
language: r
6
5
layout: base
7
-
name: Static Image Export
6
+
name: Exporting Graphs As Static Images Using Chart Studio
8
7
order: 2
9
8
output:
10
9
html_document:
11
10
keep_md: true
12
11
page_type: example_index
13
-
permalink: r/static-image-export/
12
+
permalink: r/chart-studio-image-export/
14
13
sitemap: false
15
14
thumbnail: thumbnail/png-export.png
16
15
---
17
16
18
-
### New to Plotly?
19
17
20
-
Plotly's R library is free and open source!<br>
21
-
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
22
-
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
23
-
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
18
+
### Supported File Formats
24
19
25
-
### Version Check
20
+
With the `plotly` R package, you can export graphs you create as static images in the `.png` and/or `.jpg`/`.jpeg` file formats for free using the [Chart Studio web service](https://chart-studio.plot.ly/create/#/).
26
21
27
-
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
28
-
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
22
+
Currently, exporting graphs you create as static images in the `.eps`, `.svg`, and/or `.pdf` format is a feature that is available only to users of [Chart Studio Enterprise](https://plot.ly/online-chart-maker/).
29
23
24
+
**Note:** It is important to be aware that R graphs containing WebGL-based traces (i.e. of type `scattergl`, `heatmapgl`, `contourgl`, `scatter3d`, `surface`, `mesh3d`, `scatterpolargl`, `cone`, `streamtube`, `splom`, and/or `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 `.eps`, `.svg`, and/or `.pdf`.
30
25
31
-
```r
32
-
library(plotly)
33
-
packageVersion('plotly')
34
-
```
35
-
36
-
```
37
-
## [1] '4.5.6.9000'
38
-
```
26
+
### Exporting Chart Studio Charts As Static Images
39
27
40
-
### Supported Formats
28
+
To export your R graphs as static images using the Chart Studio web service, you can use the built-in `plotly_IMAGE()` function.
41
29
42
-
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] (https://plot.ly/products/cloud/)
30
+
#### Create A Chart Studio Account And Get An API Key
43
31
44
-
**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.
32
+
To use the `plotly_IMAGE()` function, you will need to have a [Chart Studio account](https://chart-studio.plot.ly/Auth/login/?action=signup#/) and an API key (which can be found [in your Chart Studio account online settings](https://plot.ly/settings/api)). Learn more about [getting started with Chart Studio in R](https://plot.ly/r/getting-started-with-chart-studio).
45
33
46
-
To access the image in a particular format, you can either:
34
+
#### Set Environment Variables In Your R Session
47
35
48
-
49
-
* use the `orca()` function. [Orca](https://github.com/plotly/orca) is Plotly's command line applications for generating static images.
50
-
51
-
* export the image on plotly's servers using `plotly_IMAGE()`.
52
-
53
-
* append the format extension to the plot url. i.e. the JPG version of the plot: https://plot.ly/~chris/1638 is available at : https://plot.ly/~chris/1638.jpg.
54
-
55
-
### Export Locally
56
-
57
-
`4.7.900` and above includes the `orca()` function (replacing the `export()` function), which exports images locally, but requires the processx package:
36
+
Let the R session know about your Chart Studio authorization credentials by setting environment variables using [`Sys.setenv()`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Sys.setenv).
58
37
59
38
60
39
```r
61
-
if (!require("processx")) install.packages("processx")
62
-
63
-
p<- plot_ly(z=~volcano) %>% add_surface()
64
-
65
-
orca(p, "surface-plot.png")
40
+
Sys.setenv("plotly_username"="YOUR USER NAME")
41
+
Sys.setenv("plotly_api_key"="YOUR API KEY")
66
42
```
67
43
68
-
### Export Using Your Plotly Account
69
-
70
-
Another option is to do image export through your plotly account.
71
-
72
-
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.
73
-
44
+
#### Use The Development Version Of The `plotly` R Package
74
45
46
+
You will also need to be using the development version of the `plotly` R package in order to use the `plotly_IMAGE()` function. This can be installed from GitHub using the [`devtools`](https://cran.r-project.org/web/packages/devtools/index.html) R package by running the following command in your R session:
75
47
76
48
```r
77
-
Sys.setenv("plotly_username"="YOUR USER NAME")
78
-
Sys.setenv("plotly_api_key"="YOUR API KEY")
49
+
devtools::install_github("ropensci/plotly")
79
50
```
80
51
81
-
This option will export the image on plotly's servers and write the content to a local file `"output.png"` in your working directory.
52
+
#### Export R Graph As Static Image
53
+
54
+
The `plotly_IMAGE()` function exports your R plots as static images using the Chart Studio web service. The image will be stored in a file in the working directory of your R session.
### Alternative Methods Of Exporting Graphs As Static Images In R
66
+
67
+
#### Local Image Export
68
+
69
+
As an alternative to using the Chart Studio web service to export your R graphs as static images, you can [use the built-in `orca()` function](https://plot.ly/r/static-image-export) to export images locally.
70
+
71
+
#### Embed R Charts in RMarkdown Documents
93
72
94
-
You can also view the static version of any Plotly graph by appending `.png`,
95
-
`.pdf`, `.eps`, or `.svg` to the end of the URL. For example, view the static image of <https://plot.ly/~chris/1638> at <https://plot.ly/~chris/1638.png>. See [Using Plotly with rmarkdown/knitr](https://plot.ly/r/knitr/) for a way to embed these links in rmarkdown/knitr (Rmd) files.
73
+
See [Embedding Graphs in RMarkdown](https://plot.ly/r/embedding-graphs-in-rmarkdown/) to learn more about embedding R charts in RMarkdown (.Rmd) files.
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br>
25
-
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br>
26
-
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started!
27
-
28
-
### Version Check
29
-
30
-
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
31
-
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
32
-
```{r}
33
-
library(plotly)
34
-
packageVersion('plotly')
35
-
```
36
-
37
-
#### Save Plot to Server
38
-
To create a plotly figure on a plotly server, use `api_create()`.
23
+
Using the `plotly` R package, you can create a Chart Studio figure based on your R chart. Simply pass your chart as a parameter to the `api_create()` function:
39
24
40
25
```{r}
41
26
library(plotly)
42
-
p <- plot_ly(x = c(1, 2), y = c(1, 2))
27
+
p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
43
28
api_create(p)
44
29
```
45
30
46
-
#### Overwrite Plot
31
+
### How To Overwrite An Existing Plot
32
+
33
+
By default, when you call `api_create()`, a new plot is created in your Chart Studio account with its own unique URL.
47
34
48
-
If you don't include a filename, a new plot will be made on your online plotly account. If you want to overwrite a plot (i.e., keep the graph served from the same plotly URL), specify a filename. This implicitly overwrites your plotly graph.
35
+
If you would like to overwrite an existing plot in your Chart Studio account and keep the same URL, then supply a `filename` as an extra parameter to the `api_create()` function. This will keep the same URL for the plot.
If the filename contains "/", it will automatically create a plotly folder. This option is only available for [Pro-Subscriptions](https://plot.ly/products/cloud/)
41
+
### Saving Plots In Folders
42
+
43
+
If the `filename` parameter contains the character "/", then the `api_create()` function will save that plot in a folder in your Chart Studio account.
44
+
45
+
This option is only available for [Chart Studio Enterprise subscribers](https://plot.ly/online-chart-maker/)
0 commit comments