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

Function to_image

plotly/io/_kaleido.py:225–422  ·  view source on GitHub ↗

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

(
    fig: Union[dict, plotly.graph_objects.Figure],
    format: Union[str, None] = None,
    width: Union[int, None] = None,
    height: Union[int, None] = None,
    scale: Union[int, float, None] = None,
    validate: bool = True,
    # Deprecated
    engine: Union[str, None] = None,
)

Source from the content-addressed store, hash-verified

223
224
225def to_image(
226 fig: Union[dict, plotly.graph_objects.Figure],
227 format: Union[str, None] = None,
228 width: Union[int, None] = None,
229 height: Union[int, None] = None,
230 scale: Union[int, float, None] = None,
231 validate: bool = True,
232 # Deprecated
233 engine: Union[str, None] = None,
234) -> bytes:
235 """
236 Convert a figure to a static image bytes string
237
238 Parameters
239 ----------
240 fig:
241 Figure object or dict representing a figure
242
243 format: str or None
244 The desired image format. One of
245 - 'png'
246 - 'jpg' or 'jpeg'
247 - 'webp'
248 - 'svg'
249 - 'pdf'
250 - 'eps' (deprecated) (Requires the poppler library to be installed and on the PATH)
251
252 If not specified, will default to:
253 - `plotly.io.defaults.default_format` if engine is "kaleido"
254 - `plotly.io.orca.config.default_format` if engine is "orca" (deprecated)
255
256 width: int or None
257 The width of the exported image in layout pixels. If the `scale`
258 property is 1.0, this will also be the width of the exported image
259 in physical pixels.
260
261 If not specified, will default to:
262 - `plotly.io.defaults.default_width` if engine is "kaleido"
263 - `plotly.io.orca.config.default_width` if engine is "orca" (deprecated)
264
265 height: int or None
266 The height of the exported image in layout pixels. If the `scale`
267 property is 1.0, this will also be the height of the exported image
268 in physical pixels.
269
270 If not specified, will default to:
271 - `plotly.io.defaults.default_height` if engine is "kaleido"
272 - `plotly.io.orca.config.default_height` if engine is "orca" (deprecated)
273
274 scale: int or float or None
275 The scale factor to use when exporting the figure. A scale factor
276 larger than 1.0 will increase the image resolution with respect
277 to the figure's layout pixel dimensions. Whereas as scale factor of
278 less than 1.0 will decrease the image resolution.
279
280 If not specified, will default to:
281 - `plotly.io.defaults.default_scale` if engine is "kaleido"
282 - `plotly.io.orca.config.default_scale` if engine is "orca" (deprecated)

Callers 1

write_imageFunction · 0.70

Calls 6

kaleido_availableFunction · 0.85
validate_executableFunction · 0.85
kaleido_majorFunction · 0.85
getMethod · 0.45
transformMethod · 0.45

Tested by

no test coverage detected