From 4d60f5b867103e5ac4dab6dd9252faf5ad388e7c Mon Sep 17 00:00:00 2001 From: Winston Sebastian Pais <51374812+WinstonPais@users.noreply.github.com> Date: Wed, 20 May 2020 04:57:22 +0530 Subject: [PATCH 1/2] Update static-image-export.md Added Documentation for Installing Orca on Google Colab. --- doc/python/static-image-export.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/python/static-image-export.md b/doc/python/static-image-export.md index 1ea419b3d08..9ef4a501fc0 100644 --- a/doc/python/static-image-export.md +++ b/doc/python/static-image-export.md @@ -157,6 +157,31 @@ 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 039cb80f4dfd304149afa0b3e473d912139dd920 Mon Sep 17 00:00:00 2001 From: Nicolas Kruchten Date: Fri, 22 May 2020 09:18:10 -0400 Subject: [PATCH 2/2] region blocks to avoid execution --- doc/python/static-image-export.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/python/static-image-export.md b/doc/python/static-image-export.md index 9ef4a501fc0..e62a0ed3294 100644 --- a/doc/python/static-image-export.md +++ b/doc/python/static-image-export.md @@ -157,6 +157,7 @@ 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 @@ -170,7 +171,6 @@ 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") ``` @@ -182,6 +182,7 @@ 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.