lets_plot.ggsave

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

Exports plot or “bunch” to a file. Supported formats: 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).

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.

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)