Skip to content

Commit 2beaaf0

Browse files
Merge pull request #2492 from plotly/colab_doc
Colab doc
2 parents a8a952d + 039cb80 commit 2beaaf0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

doc/python/static-image-export.md

+26
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,32 @@ fig.write_image("images/fig1.eps")
157157

158158
**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.
159159

160+
<!-- #region -->
161+
### Install orca on Google Colab
162+
```
163+
!pip install plotly>=4.7.1
164+
!wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage -O /usr/local/bin/orca
165+
!chmod +x /usr/local/bin/orca
166+
!apt-get install xvfb libgtk2.0-0 libgconf-2-4
167+
```
168+
169+
Once this is done you can use this code to make, show and export a figure:
170+
171+
```python
172+
import plotly.graph_objects as go
173+
fig = go.Figure( go.Scatter(x=[1,2,3], y=[1,3,2] ) )
174+
fig.write_image("fig1.svg")
175+
fig.write_image("fig1.png")
176+
```
177+
178+
The files can then be downloaded with:
179+
180+
```python
181+
from google.colab import files
182+
files.download('fig1.svg')
183+
files.download('fig1.png')
184+
```
185+
<!-- #endregion -->
160186

161187
### Get Image as Bytes
162188
The `plotly.io.to_image` function is used to return an image as a bytes object. You can also use the `.to_image` graph object figure method.

0 commit comments

Comments
 (0)