From 91de4a1a1ea6e7d8939fe316293243432e6acf78 Mon Sep 17 00:00:00 2001 From: WinstonPais <51374812+WinstonPais@users.noreply.github.com> Date: Tue, 19 May 2020 10:31:58 +0530 Subject: [PATCH 1/2] Update static-image-export.md Added Documentation for Installing Orca on Google Colab. --- doc/python/static-image-export.md | 33 ++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/doc/python/static-image-export.md b/doc/python/static-image-export.md index 1ea419b3d0..530070ec8a 100644 --- a/doc/python/static-image-export.md +++ b/doc/python/static-image-export.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.1' - jupytext_version: 1.1.6 + format_version: '1.2' + jupytext_version: 1.4.2 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.7.3 + version: 3.6.10 plotly: description: Plotly allows you to save static images of your plots. Save the image to your local computer, or embed it inside your Jupyter notebooks as a static @@ -157,6 +157,33 @@ fig.write_image("images/fig1.eps") **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. + +### Install orca on Google Colab +``` +!pip install plotly>=4.7.1 +!wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage -O /usr/local/bin/orca +!chmod +x /usr/local/bin/orca +!apt-get install xvfb libgtk2.0-0 libgconf-2-4 +``` + +Once this is done you can use this code to make, show and export a figure: + + +```python +import plotly.graph_objects as go +fig = go.Figure( go.Scatter(x=[1,2,3], y=[1,3,2] ) ) +fig.show() +fig.write_image("fig1.svg") +fig.write_image("fig1.png") +``` + +The files can then be downloaded with: + +```python +from google.colab import files +files.download('fig1.svg') +files.download('fig1.png') +``` ### Get Image as Bytes 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. From 80ae2d614ad4877ce0cb7eb59bd6bb23a9995322 Mon Sep 17 00:00:00 2001 From: WinstonPais <51374812+WinstonPais@users.noreply.github.com> Date: Tue, 19 May 2020 12:36:25 +0530 Subject: [PATCH 2/2] Update static-image-export.md reverted to the original version of jupytext --- doc/python/static-image-export.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/python/static-image-export.md b/doc/python/static-image-export.md index 530070ec8a..08668088cc 100644 --- a/doc/python/static-image-export.md +++ b/doc/python/static-image-export.md @@ -5,8 +5,8 @@ jupyter: text_representation: extension: .md format_name: markdown - format_version: '1.2' - jupytext_version: 1.4.2 + format_version: '1.1' + jupytext_version: 1.1.6 kernelspec: display_name: Python 3 language: python @@ -20,7 +20,7 @@ jupyter: name: python nbconvert_exporter: python pygments_lexer: ipython3 - version: 3.6.10 + version: 3.7.3 plotly: description: Plotly allows you to save static images of your plots. Save the image to your local computer, or embed it inside your Jupyter notebooks as a static