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

Function write_image

plotly/io/_orca.py:1554–1670  ·  view source on GitHub ↗

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

(
    fig, file, format=None, scale=None, width=None, height=None, validate=True
)

Source from the content-addressed store, hash-verified

1552
1553
1554def write_image(
1555 fig, file, format=None, scale=None, width=None, height=None, validate=True
1556):
1557 """
1558 Convert a figure to a static image and write it to a file or writeable
1559 object
1560
1561 Parameters
1562 ----------
1563 fig:
1564 Figure object or dict representing a figure
1565
1566 file: str or writeable
1567 A string representing a local file path or a writeable object
1568 (e.g. a pathlib.Path object or an open file descriptor)
1569
1570 format: str or None
1571 The desired image format. One of
1572 - 'png'
1573 - 'jpg' or 'jpeg'
1574 - 'webp'
1575 - 'svg'
1576 - 'pdf'
1577 - 'eps' (Requires the poppler library to be installed)
1578
1579 If not specified and `file` is a string then this will default to the
1580 file extension. If not specified and `file` is not a string then this
1581 will default to `plotly.io.config.default_format`
1582
1583 width: int or None
1584 The width of the exported image in layout pixels. If the `scale`
1585 property is 1.0, this will also be the width of the exported image
1586 in physical pixels.
1587
1588 If not specified, will default to `plotly.io.config.default_width`
1589
1590 height: int or None
1591 The height of the exported image in layout pixels. If the `scale`
1592 property is 1.0, this will also be the height of the exported image
1593 in physical pixels.
1594
1595 If not specified, will default to `plotly.io.config.default_height`
1596
1597 scale: int or float or None
1598 The scale factor to use when exporting the figure. A scale factor
1599 larger than 1.0 will increase the image resolution with respect
1600 to the figure's layout pixel dimensions. Whereas as scale factor of
1601 less than 1.0 will decrease the image resolution.
1602
1603 If not specified, will default to `plotly.io.config.default_scale`
1604
1605 validate: bool
1606 True if the figure should be validated before being converted to
1607 an image, False otherwise.
1608
1609 Returns
1610 -------
1611 None

Callers 1

renderMethod · 0.90

Calls 3

to_imageFunction · 0.70
formatMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected