lets_plot.ggsave

lets_plot.ggsave(plot: Union[lets_plot.plot.core.PlotSpec, lets_plot.plot.subplots.SupPlotsSpec, lets_plot.plot.plot.GGBunch], filename: str, *, path: Optional[str] = None, iframe: bool = True, scale: float = 2.0) str

Export plot or bunch to a file. Supported formats: PNG, SVG, HTML.

The exported file is created in directory ${user.dir}/lets-plot-images if not specified otherwise (see the path parameter).

Parameters
plotPlotSpec or GGBunch

Plot specification to export.

filenamestr

The name of file. It must end with a file extension corresponding to one of the supported formats: SVG, HTML (or HTM), PNG (requires CairoSVG library).

pathstr

Path to a directory to save image files in. By default it is ${user.dir}/lets-plot-images.

iframebool, default=True

Whether to wrap HTML page into a iFrame. Only applicable when exporting to HTML.

scalefloat, default=2.0

Scaling factor for raster output. Only applicable when exporting to PNG.

Returns
str

Absolute pathname of created file.

Examples

1from lets_plot import *
2LetsPlot.setup_html()
3plot = ggplot() + geom_point(x=0, y=0)
4ggsave(plot, 'plot.html', path='.', iframe=False)