MCPcopy Index your code
hub / github.com/plotly/plotly.py / to_image

Method to_image

plotly/basedatatypes.py:3714–3801  ·  view source on GitHub ↗

Convert a figure to a static image bytes string Parameters ---------- format: str or None The desired image format. One of - 'png' - 'jpg' or 'jpeg' - 'webp' - 'svg' - 'pdf'

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

3712 return pio.write_html(self, *args, **kwargs)
3713
3714 def to_image(self, *args, **kwargs):
3715 """
3716 Convert a figure to a static image bytes string
3717
3718 Parameters
3719 ----------
3720 format: str or None
3721 The desired image format. One of
3722 - 'png'
3723 - 'jpg' or 'jpeg'
3724 - 'webp'
3725 - 'svg'
3726 - 'pdf'
3727 - 'eps' (deprecated) (Requires the poppler library to be installed)
3728
3729 If not specified, will default to:
3730 - `plotly.io.defaults.default_format` if engine is "kaleido"
3731 - `plotly.io.orca.config.default_format` if engine is "orca" (deprecated)
3732
3733 width: int or None
3734 The width of the exported image in layout pixels. If the `scale`
3735 property is 1.0, this will also be the width of the exported image
3736 in physical pixels.
3737
3738 If not specified, will default to:
3739 - `plotly.io.defaults.default_width` if engine is "kaleido"
3740 - `plotly.io.orca.config.default_width` if engine is "orca" (deprecated)
3741
3742 height: int or None
3743 The height of the exported image in layout pixels. If the `scale`
3744 property is 1.0, this will also be the height of the exported image
3745 in physical pixels.
3746
3747 If not specified, will default to:
3748 - `plotly.io.defaults.default_height` if engine is "kaleido"
3749 - `plotly.io.orca.config.default_height` if engine is "orca" (deprecated)
3750
3751 scale: int or float or None
3752 The scale factor to use when exporting the figure. A scale factor
3753 larger than 1.0 will increase the image resolution with respect
3754 to the figure's layout pixel dimensions. Whereas as scale factor of
3755 less than 1.0 will decrease the image resolution.
3756
3757 If not specified, will default to:
3758 - `plotly.io.defaults.default_scale` if engine is "kaliedo"
3759 - `plotly.io.orca.config.default_scale` if engine is "orca" (deprecated)
3760
3761 validate: bool
3762 True if the figure should be validated before being converted to
3763 an image, False otherwise.
3764
3765 engine (deprecated): str
3766 Image export engine to use. This parameter is deprecated and Orca engine support will be
3767 dropped in the next major Plotly version. Until then, the following values are supported:
3768 - "kaleido": Use Kaleido for image export
3769 - "orca": Use Orca for image export
3770 - "auto" (default): Use Kaleido if installed, otherwise use Orca
3771

Callers 8

test_image_rendererFunction · 0.80
test_bytesioFunction · 0.80
test_defaultsFunction · 0.80
test_fig_to_imageFunction · 0.80

Calls 3

kaleido_availableFunction · 0.90
kaleido_majorFunction · 0.90
getMethod · 0.45

Tested by 8

test_image_rendererFunction · 0.64
test_bytesioFunction · 0.64
test_defaultsFunction · 0.64
test_fig_to_imageFunction · 0.64