Skip to content

Commit 6ba54f3

Browse files
committed
Update static-image-export.md
1 parent 07fd630 commit 6ba54f3

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

doc/python/static-image-export.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.16.4
9+
jupytext_version: 1.17.0
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.11.10
23+
version: 3.13.2
2424
plotly:
2525
description: Plotly allows you to save static images of your plots. Save the image
2626
to your local computer, or embed it inside your Jupyter notebooks as a static
@@ -58,7 +58,7 @@ It's also possible to generate static images using [Orca](https://github.com/plo
5858

5959
Kaleido uses Chrome for static image generation. Versions of Kaleido prior to v1 included Chrome. Kaleido v1 and later uses the Chrome that's available on the machine on which it's running. If you need to install Chrome for static image generation, Plotly provides a CLI.
6060

61-
Run `plotly_get_chrome` to install Chrome.
61+
Run `plotly_get_chrome` to install Chrome.
6262

6363
You can also install Chrome from within Python using `plotly.io.install_chrome()`
6464

@@ -71,14 +71,14 @@ pio.install_chrome()
7171

7272
## Write Image to a File
7373

74-
Plotly figures have a `write_image` method to write a figure to a file. `write_image` supports PNG, JPEG, WebP, SVG, and PDF.
74+
Plotly figures have a `write_image` method to write a figure to a file. `write_image` supports PNG, JPEG, WebP, SVG, and PDF.
7575

76-
To export a figure using `write_image`, call `write_image` on the figure, and pass as an argument the filename where you want to save the figure. The file format is inferred from the extension:
76+
To export a figure using `write_image`, call `write_image` on the figure, and pass as an argument the filename where you want to save the figure. The file format is inferred from the extension:
7777

7878

7979
### Raster Formats
8080

81-
**PNG**
81+
**PNG**
8282
~~~python
8383
import plotly.express as px
8484
data_canada = px.data.gapminder().query("country == 'Canada'")
@@ -145,19 +145,17 @@ fig.write_image("fig1", format="png")
145145

146146
## Get Image as Bytes
147147

148-
As well as exporting to a file, Plotly figures also support conversion to a bytes object.
148+
As well as exporting to a file, Plotly figures also support conversion to a bytes object.
149149
To convert a figure to a **PNG** bytes object, call the figure's `to_image` method with a `format`
150150

151151
```python
152152
import plotly.express as px
153153
data_canada = px.data.gapminder().query("country == 'Canada'")
154154
fig = px.bar(data_canada, x='year', y='pop')
155-
156155
img_bytes = fig.to_image(format="png")
157156
```
158157

159-
### Display Bytes as Image Using `IPython.display.Image`
160-
A bytes object representing a PNG image can be displayed directly in the notebook using the `IPython.display.Image` class. This also works in the [Qt Console for Jupyter](https://qtconsole.readthedocs.io/en/stable/)!
158+
Here's the bytes object displayed using `IPython.display.Image`:
161159

162160
```python
163161
from IPython.display import Image
@@ -214,11 +212,11 @@ pio.write_image(fig, "fig.png")
214212

215213
## Image Export Settings (Kaleido)
216214

217-
As well as configuring height, width, and other settings by passing arguments when calling `write_image` and `to_image`, you can also set a single default to be used throughout the duration of the program.
215+
As well as configuring height, width, and other settings by passing arguments when calling `write_image` and `to_image`, you can also set a single default to be used throughout the duration of the program.
218216

219217
### Available Settings
220218

221-
The following settings are availble.
219+
The following settings are availble.
222220

223221
`default_width`: The default pixel width to use on image export.
224222

0 commit comments

Comments
 (0)