plotly.io.write_image

plotly.io.write_image(fig: Union[dict, plotly.graph_objects._figure.Figure], file: Union[str, pathlib.Path], format: Optional[str] = None, scale: Optional[Union[int, float]] = None, width: Optional[int] = None, height: Optional[int] = None, validate: bool = True)

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.Path object or an open file descriptor)

  • format (str) –

    (optional) The desired image format. One of:
    • ’png’

    • ’jpg’ or ‘jpeg’

    • ’webp’

    • ’svg’

    • ’pdf’

    Defaults to the file extension of file, if given; otherwise defaults to plotly.io.defaults.default_format.

  • width (int) – (optional) The width of the exported image in layout pixels. If the scale property is 1.0, this will also be the width of the exported image in physical pixels. Defaults to plotly.io.defaults.default_width.

  • height (int) – (optional) The height of the exported image in layout pixels. If the scale property is 1.0, this will also be the height of the exported image in physical pixels. Defaults to plotly.io.defaults.default_height.

  • scale (int or float) – (optional) 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, while a scale factor of less than 1.0 will decrease the image resolution. Defaults to plotly.io.defaults.default_scale.

  • validate (bool) – (optional) True if the figure should be validated before being converted to an image, False otherwise. Defaults to True.

Returns

Return type

None