Framework for Python

Saving Work

save_figure()

Save a figure to the figures output folder.

Usage

save_figure(
    plot: Any,
    name: str,
    format: str = 'png',
    width: float = 8,
    height: float = 6,
    dpi: int = 300,
    public: bool = False,
    overwrite: bool = True,
    **kwargs: Any,
) -> Path

Arguments

Name Type Default Description
plot required Any

A matplotlib or seaborn figure (anything with savefig()), a plotnine plot (anything with save()), or None for the current matplotlib figure.

name required str

File name without extension.

format str 'png'

png, pdf, svg, jpg, jpeg, or tiff.

width float 8

Width in inches.

height float 6

Height in inches.

dpi int 300

Resolution for raster formats.

public bool False

In a sensitive project, save to the public figures folder.

overwrite bool True

Replace an existing file.

**kwargs Any

Passed to savefig() or save().

Value

The saved file.