otter.plotting.save_figure

otter.plotting.save_figure(fig: Any, output_stem: str | Path, *, formats: Sequence[str] | str = ('png', 'pdf'), dpi: int = 300, tight: bool = True, pad_inches: float = 0.03, close: bool = False, **kwargs: Any) dict[str, Path][source]

Save matching raster and vector copies of a figure.

Parameters:
  • fig – A Matplotlib figure.

  • output_stem – Destination without a suffix. A trailing .png or .pdf is accepted and removed before all requested formats are written.

  • formats – Output suffixes. The default writes a 300 dpi PNG and a vector PDF.

  • dpi – Raster resolution. Matplotlib also uses this value for any rasterized artists embedded in the PDF; vector lines and text remain vector.

  • tight – Use Matplotlib’s tight bounding-box calculation. Set this to False when exact physical dimensions are more important than trimming.

  • pad_inches – Padding used with a tight bounding box.

  • close – Close the figure after every requested file has been written.

Returns:

dict – Mapping from lowercase format name to the written path.

Examples using save_figure

Carbon structure factors: Otter PA-HNC and DFT-MD

Carbon structure factors: Otter PA-HNC and DFT-MD

Bethkenhagen et al. carbon-ionization comparison

Bethkenhagen et al. carbon-ionization comparison

Polypropylene (PP/CH2): HNC versus same-potential MD

Polypropylene (PP/CH2): HNC versus same-potential MD

Ion-structure literature library

Ion-structure literature library

Two-temperature aluminium: Johnson et al. (2025)

Two-temperature aluminium: Johnson et al. (2025)

Equilibrium aluminium structure factors: Schörner et al. (2022)

Equilibrium aluminium structure factors: Schörner et al. (2022)

Starrett et al. CH1.36 mixture pair distributions

Starrett et al. CH1.36 mixture pair distributions

Single-species Starrett–Saumon ion-structure benchmarks

Single-species Starrett--Saumon ion-structure benchmarks

Al: complete electronic-to-ionic workflow

Al: complete electronic-to-ionic workflow

Experimental IS/SC feedback for aluminium

Experimental IS/SC feedback for aluminium

Aluminium KS-DFT and Thomas–Fermi comparison

Aluminium KS-DFT and Thomas--Fermi comparison

Al: elastic Rayleigh weight versus density

Al: elastic Rayleigh weight versus density

Carbon ionization and pressure-ionization levels

Carbon ionization and pressure-ionization levels

Carbon: local-field-correction sensitivity

Carbon: local-field-correction sensitivity

CH1.36: multicomponent electronic-to-ionic workflow

CH1.36: multicomponent electronic-to-ionic workflow