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

Function write_images

plotly/io/_kaleido.py:560–724  ·  view source on GitHub ↗

Write multiple images to files or writeable objects. This is much faster than calling write_image() multiple times. This function can only be used with the Kaleido engine, v1.0.0 or greater. This function accepts the same arguments as write_image() (minus the `engine` argument),

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

Source from the content-addressed store, hash-verified

558
559
560def write_images(
561 fig: Union[
562 List[Union[dict, plotly.graph_objects.Figure]],
563 Union[dict, plotly.graph_objects.Figure],
564 ],
565 file: Union[List[Union[str, Path]], Union[str, Path]],
566 format: Union[List[Union[str, None]], Union[str, None]] = None,
567 scale: Union[List[Union[int, float, None]], Union[int, float, None]] = None,
568 width: Union[List[Union[int, None]], Union[int, None]] = None,
569 height: Union[List[Union[int, None]], Union[int, None]] = None,
570 validate: Union[List[bool], bool] = True,
571) -> None:
572 """
573 Write multiple images to files or writeable objects. This is much faster than
574 calling write_image() multiple times. This function can only be used with the Kaleido
575 engine, v1.0.0 or greater.
576
577 This function accepts the same arguments as write_image() (minus the `engine` argument),
578 except that any of the arguments may be either a single value or an iterable of values.
579 If multiple arguments are iterable, they must all have the same length.
580
581 Parameters
582 ----------
583 fig:
584 List of figure objects or dicts representing a figure.
585 Also accepts a single figure or dict representing a figure.
586
587 file: str, pathlib.Path, or list of (str or pathlib.Path)
588 List of str or pathlib.Path objects representing local file paths to write to.
589 Can also be a single str or pathlib.Path object if fig argument is
590 a single figure or dict representing a figure.
591
592 format: str, None, or list of (str or None)
593 The image format to use for exported images.
594 Supported formats are:
595 - 'png'
596 - 'jpg' or 'jpeg'
597 - 'webp'
598 - 'svg'
599 - 'pdf'
600
601 Use a list to specify formats for each figure or dict in the list
602 provided to the `fig` argument.
603 Specify format as a `str` to apply the same format to all exported images.
604 If not specified, and the corresponding `file` argument has a file extension, then `format` will default to the
605 file extension. Otherwise, will default to `plotly.io.defaults.default_format`.
606
607 width: int, None, or list of (int or None)
608 The width of the exported image in layout pixels. If the `scale`
609 property is 1.0, this will also be the width of the exported image
610 in physical pixels.
611
612 Use a list to specify widths for each figure or dict in the list
613 provided to the `fig` argument.
614 Specify width as an `int` to apply the same width to all exported images.
615 If not specified, will default to `plotly.io.defaults.default_width`.
616
617 height: int, None, or list of (int or None)

Callers

nothing calls this directly

Calls 7

broadcast_args_to_dictsFunction · 0.90
kaleido_availableFunction · 0.85
kaleido_majorFunction · 0.85
as_path_objectFunction · 0.85
infer_formatFunction · 0.85
versionMethod · 0.45

Tested by

no test coverage detected