plotly.io.write_image¶
-
plotly.io.write_image(fig: Union[dict, plotly.graph_objects._figure.Figure], file: Union[str, pathlib.Path], format: Optional[str] = None, scale: Optional[Union[int, float]] = None, width: Optional[int] = None, height: Optional[int] = None, validate: bool = True, engine: Optional[str] = 'auto')¶ Convert a figure to a static image and write it to a file or writeable object
- Parameters
fig – Figure object or dict representing a figure
file (str or writeable) – A string representing a local file path or a writeable object (e.g. a pathlib.Path object or an open file descriptor)
- The desired image format. One of
’png’
’jpg’ or ‘jpeg’
’webp’
’svg’
’pdf’
’eps’ (deprecated) (Requires the poppler library to be installed and on the PATH)
If not specified and
fileis a string then this will default to the file extension. If not specified andfileis not a string then this will default to:plotly.io.defaults.default_formatif engine is “kaleido”plotly.io.orca.config.default_formatif engine is “orca” (deprecated)
The width of the exported image in layout pixels. If the
scaleproperty is 1.0, this will also be the width of the exported image in physical pixels.- If not specified, will default to:
plotly.io.defaults.default_widthif engine is “kaleido”plotly.io.orca.config.default_widthif engine is “orca” (deprecated)
The height of the exported image in layout pixels. If the
scaleproperty is 1.0, this will also be the height of the exported image in physical pixels.- If not specified, will default to:
plotly.io.defaults.default_heightif engine is “kaleido”plotly.io.orca.config.default_heightif engine is “orca” (deprecated)
scale (int or float or None) –
The scale factor to use when exporting the figure. A scale factor larger than 1.0 will increase the image resolution with respect to the figure’s layout pixel dimensions. Whereas as scale factor of less than 1.0 will decrease the image resolution.
- If not specified, will default to:
plotly.io.defaults.default_scaleif engine is “kaleido”plotly.io.orca.config.default_scaleif engine is “orca” (deprecated)
validate (bool) – True if the figure should be validated before being converted to an image, False otherwise.
(deprecated) (engine) –
Image export engine to use. This parameter is deprecated and Orca engine support will be dropped in the next major Plotly version. Until then, the following values are supported:
”kaleido”: Use Kaleido for image export
”orca”: Use Orca for image export
”auto” (default): Use Kaleido if installed, otherwise use Orca
- Returns
- Return type
