save#
- save(plot: PlotSpec | SupPlotsSpec | GGBunch, filename: str, *, path: str = '.', iframe: bool = True, scale: float = 1.0, w: int | float | None = None, h: int | float | None = None, unit: Literal['in', 'cm', 'mm', 'px'] = 'in', dpi: int = 300) str#
Convenience function for exporting plots.
Supported formats: PNG, SVG, PDF, HTML.
- Parameters:
plot (
PlotSpec|SupPlotsSpec|GGBunch) – Plot to export.filename (
str) – Name of the file. It must end with a file extension corresponding to one of the supported formats: SVG, HTML (or HTM), PNG, PDF (requires the pillow library).path (
str, default'.') – Path to the folder to save image files in. By default, it is current working directory.iframe (
bool, defaultTrue) – Whether to wrap the HTML page into an iFrame. Only applicable when exporting to HTML. Some browsers may not display some UTF-8 characters correctly when setting iframe=Truescale (
float, default2.0) – Scaling factor for raster output. Only applicable when exporting to PNG or PDF.w (
float, defaultNone) – Width of the output image in units. Only applicable when exporting to SVG, PNG, or PDF.h (
float, defaultNone) – Height of the output image in units. Only applicable when exporting to SVG, PNG, or PDF.unit (
{'in', 'cm', 'mm', 'px'}, default'in') – Unit of the output image. One of: ‘in’, ‘cm’, ‘mm’ or ‘px’. Only applicable when exporting to SVG, PNG, or PDF.dpi (
int, default300) –Resolution in dots per inch. Only applicable when exporting to PNG or PDF. The default value depends on the unit:
for ‘px’ it is 96 (output image will have the same pixel size as
w, andhvalues)for physical units (‘in’, ‘cm’, ‘mm’) it is 300.
- Returns:
str– Absolute pathname of the created file.
Notes
This function is a``ggsave`` wrapper. The docstrings for this function are copied from lets_plot ggsave function.
The original ggsave function: https://lets-plot.org/python/pages/api/lets_plot.ggsave.html