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

Function to_image

plotly/io/_orca.py:1362–1551  ·  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, format=None, width=None, height=None, scale=None, validate=True)

Source from the content-addressed store, hash-verified

1360
1361
1362def to_image(fig, format=None, width=None, height=None, scale=None, validate=True):
1363 """
1364 Convert a figure to a static image bytes string
1365
1366 Parameters
1367 ----------
1368 fig:
1369 Figure object or dict representing a figure
1370
1371 format: str or None
1372 The desired image format. One of
1373 - 'png'
1374 - 'jpg' or 'jpeg'
1375 - 'webp'
1376 - 'svg'
1377 - 'pdf'
1378 - 'eps' (Requires the poppler library to be installed)
1379
1380 If not specified, will default to `plotly.io.config.default_format`
1381
1382 width: int or None
1383 The width of the exported image in layout pixels. If the `scale`
1384 property is 1.0, this will also be the width of the exported image
1385 in physical pixels.
1386
1387 If not specified, will default to `plotly.io.config.default_width`
1388
1389 height: int or None
1390 The height of the exported image in layout pixels. If the `scale`
1391 property is 1.0, this will also be the height of the exported image
1392 in physical pixels.
1393
1394 If not specified, will default to `plotly.io.config.default_height`
1395
1396 scale: int or float or None
1397 The scale factor to use when exporting the figure. A scale factor
1398 larger than 1.0 will increase the image resolution with respect
1399 to the figure's layout pixel dimensions. Whereas as scale factor of
1400 less than 1.0 will decrease the image resolution.
1401
1402 If not specified, will default to `plotly.io.config.default_scale`
1403
1404 validate: bool
1405 True if the figure should be validated before being converted to
1406 an image, False otherwise.
1407
1408 Returns
1409 -------
1410 bytes
1411 The image data
1412 """
1413 # Make sure orca sever is running
1414 # -------------------------------
1415 ensure_server()
1416
1417 # Handle defaults
1418 # ---------------
1419 # Apply configuration defaults to unspecified arguments

Callers 2

to_mimebundleMethod · 0.90
write_imageFunction · 0.70

Calls 8

ensure_serverFunction · 0.85
validate_coerce_formatFunction · 0.85
reset_statusFunction · 0.85
formatMethod · 0.45
decodeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected