plotly.io.to_image¶
-
plotly.io.to_image(fig: Union[dict, plotly.graph_objects._figure.Figure], format: Optional[str] = None, width: Optional[int] = None, height: Optional[int] = None, scale: Optional[Union[int, float]] = None, validate: bool = True, engine: Optional[str] = None) → bytes¶ Convert a figure to a static image bytes string
- Parameters
fig – Figure object or dict representing a figure
- 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, 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
The image data
- Return type
