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
Copy file name to clipboardExpand all lines: doc/python/orca-management.md
+55-3Lines changed: 55 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -34,13 +34,65 @@ jupyter:
34
34
---
35
35
36
36
### Overview
37
-
This section covers the lower-level details of how plotly.py uses orca to perform static image generation. Please refer to the [Static Image Export](/python/static-image-export/) section for general information on creating static images from plotly.py figures.
37
+
This section covers the lower-level details of how plotly.py can use orca to perform static image generation. Please refer to the [Static Image Export](/python/static-image-export/) section for general information on creating static images from plotly.py figures.
38
38
39
-
### What is Orca?
39
+
### What is orca?
40
40
Orca is an [Electron](https://electronjs.org/) application that inputs plotly figure specifications and converts them into static images. Orca can run as a command-line utility or as a long-running server process. In order to provide the fastest possible image export experience, plotly.py launches orca in server mode, and communicates with it over a local port. See https://github.com/plotly/orca for more information.
41
41
42
42
By default, plotly.py launches the orca server process the first time an image export operation is performed, and then leaves it running until the main Python process exits. Because of this, the first image export operation in an interactive session will typically take a couple of seconds, but then all subsequent export operations will be significantly faster, since the server is already running.
43
43
44
+
### Installing orca
45
+
There are 3 general approaches to installing orca and its Python dependencies.
46
+
47
+
##### conda
48
+
Using the [conda](https://conda.io/docs/) package manager, you can install these dependencies in a single command:
**Note:** Even if you do not want to use conda to manage your Python dependencies, it is still useful as a cross platform tool for managing native libraries and command-line utilities (e.g. git, wget, graphviz, boost, gcc, nodejs, cairo, etc.). For this use-case, start with [Miniconda](https://conda.io/miniconda.html) (~60MB) and tell the installer to add itself to your system `PATH`. Then run `conda install plotly-orca==1.2.1` and the orca executable will be available system wide.
54
+
55
+
##### npm + pip
56
+
You can use the [npm](https://www.npmjs.com/get-npm) package manager to install `orca` (and its `electron` dependency), and then use pip to install `psutil`:
57
+
58
+
```
59
+
$ npm install -g electron@1.8.4 orca
60
+
$ pip install psutil requests
61
+
```
62
+
63
+
##### Standalone Binaries + pip
64
+
If you are unable to install conda or npm, you can install orca as a precompiled binary for your operating system. Follow the instructions in the orca [README](https://github.com/plotly/orca) to install orca and add it to your system `PATH`. Then use pip to install `psutil`.
Now let's create a simple scatter plot with 100 random points of variying color and size.
@@ -207,4 +259,4 @@ In addition to the `executable` property, the `plotly.io.orca.config` object can
207
259
208
260
209
261
### Saving Configuration Settings
210
-
Configuration options can optionally be saved to the `~/.plotly/` directory by calling the `plotly.io.config.save()` method. Saved setting will be automatically loaded at the start of future sessions.
262
+
Configuration options can optionally be saved to the `~/.plotly/` directory by calling the `plotly.io.config.save()` method. Saved setting will be automatically loaded at the start of future sessions.
Copy file name to clipboardExpand all lines: doc/python/static-image-export.md
+49-49Lines changed: 49 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -41,31 +41,20 @@ Plotly figures are interactive when viewed in a web browser: you can hover over
41
41
42
42
43
43
<!-- #region -->
44
-
#### Install Dependencies
45
-
Static image generation requires the [orca](https://github.com/plotly/orca) commandline utility and the [psutil](https://github.com/giampaolo/psutil) and [requests](https://2.python-requests.org/en/master/) Python libraries. There are 3 general approach to installing these dependencies.
46
-
47
-
##### conda
48
-
Using the [conda](https://conda.io/docs/) package manager, you can install these dependencies in a single command:
44
+
#### Install Dependencies (Kaleido)
45
+
Static image generation requires the [`kaleido`](https://github.com/plotly/Kaleido) package which can be installed using pip...
**Note:** Even if you do not want to use conda to manage your Python dependencies, it is still useful as a cross platform tool for managing native libraries and command-line utilities (e.g. git, wget, graphviz, boost, gcc, nodejs, cairo, etc.). For this use-case, start with [Miniconda](https://conda.io/miniconda.html) (~60MB) and tell the installer to add itself to your system `PATH`. Then run `conda install plotly-orca==1.2.1` and the orca executable will be available system wide.
54
-
55
-
##### npm + pip
56
-
You can use the [npm](https://www.npmjs.com/get-npm) package manager to install `orca` (and its `electron` dependency), and then use pip to install `psutil`:
57
-
58
-
```
59
-
$ npm install -g electron@1.8.4 orca
60
-
$ pip install psutil requests
50
+
or conda.
61
51
```
52
+
$ conda install -c conda-forge kaleido
53
+
```
62
54
63
-
##### Standalone Binaries + pip
64
-
If you are unable to install conda or npm, you can install orca as a precompiled binary for your operating system. Follow the instructions in the orca [README](https://github.com/plotly/orca)to install orca and add it to your system `PATH`. Then use pip to install `psutil`.
55
+
####Install Dependencies (Orca)
56
+
While Kaleido is now the recommended approach, image export can also be supported by the [orca](https://github.com/plotly/orca)command line utility. See the [Orca Management](/python/orca-management/) section for instructions on installing, configuring, and troubleshooting orca.
**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 will include encapsulated rasters, instead of vectors, for some parts of the image.
In summary, to export high-quality static images from plotly.py, all you need to do is install orca, psutil, and requests and then use the `plotly.io.write_image` and `plotly.io.to_image` functions (or the `.write_image` and `.to_image` graph object figure methods).
180
+
<!-- #region -->
181
+
### Specify Image Export Engine
182
+
If `kaleido` is installed, it will automatically be used to perform image export. If it is not installed, plotly.py will attempt to use orca instead. The `engine` argument to the `to_image` and `write_image` functions can be used to override this default behavior.
183
+
184
+
Here is an example of specifying that orca should be used:
185
+
```python
186
+
fig.to_image(format="png", engine="orca")
187
+
```
188
+
189
+
And, here is an example of specifying that Kaleido should be used:
190
+
```python
191
+
fig.to_image(format="png", engine="kaleido")
192
+
```
193
+
194
+
<!-- #endregion -->
220
195
221
-
If you want to know more about how the orca integration works, or if you need to troubleshoot an issue, please check out the [Orca Management](/python/orca-management/) section.
196
+
<!-- #region -->
197
+
### Image Export Settings (Kaleido)
198
+
Various image export settings can be configured using the `plotly.io.kaleido.scope` object. For example, the `default_format` property can be used to specify that the default export format should be `svg` instead of `png`
199
+
200
+
```python
201
+
import plotly.io as pio
202
+
pio.kaleido.scope.default_format ="svg"
203
+
```
204
+
205
+
Here is a complete listing of the available image export settings:
206
+
207
+
-**`default_width`**: The default pixel width to use on image export.
208
+
-**`default_height`**: The default pixel height to use on image export.
209
+
-**`default_scale`**: The default image scale facor applied on image export.
210
+
-**`default_format`**: The default image format used on export. One of `"png"`, `"jpeg"`, `"webp"`, `"svg"`, `"pdf"`, or `"eps"`.
211
+
-**`mathjax`**: Location of the MathJax bundle needed to render LaTeX characters. Defaults to a CDN location. If fully offline export is required, set this to a local MathJax bundle.
212
+
-**`topojson`**: Location of the topojson files needed to render choropleth traces. Defaults to a CDN location. If fully offline export is required, set this to a local directory containing the [Plotly.js topojson files](https://github.com/plotly/plotly.js/tree/master/dist/topojson).
213
+
-**`mapbox_access_token`**: The default Mapbox access token.
214
+
215
+
<!-- #endregion -->
216
+
217
+
### Image Export Settings (Orca)
218
+
See the [Orca Management](/python/orca-management/) section for information on how to specify image export settings when using orca.
219
+
220
+
### Summary
221
+
In summary, to export high-quality static images from plotly.py, all you need to do is install the `kaleido` package and then use the `plotly.io.write_image` and `plotly.io.to_image` functions (or the `.write_image` and `.to_image` graph object figure methods).
0 commit comments