sysplot.save_current_figure#
- save_current_figure(chapter, number, language, suffix=None, folder=None, fmt=None, transparent=None)[source]#
Save the current Matplotlib figure with a standardized filename.
Saves the active figure next to the calling script using the naming convention
Bild_{chapter}_{number}_{script}{_suffix}.{fmt}. The output directory{script_dir}/{folder}/{language}/is created automatically if it does not exist.Warning
You can disbable all filesaves by this function by setting the environment variable
SYSPLOT_DISABLE_SAVE=1(or any non-empty value). This is useful for CI runs or test environments where writing output files is undesirable.- Parameters:
chapter (
int) – Chapter number. Must be >= 0.number (
int) – Figure number within the chapter. Must be >= 0.language (
str) – Language subdirectory (e.g.,"de"or"en").suffix (
str|int|None) – Optional variant identifier appended to the filename.folder (
str|None) – Subdirectory name relative to the calling script’s location. Defaults tosavefig_folder.fmt (
str|None) – File format (e.g.,"pdf","svg","png"). Defaults tofigure_fmt.transparent (
bool|None) – Whether to save with a transparent background. Defaults tosavefig_transparent.
- Return type:
Path|None- Returns:
Path of the saved file, or
Noneif saving is disabled via theSYSPLOT_DISABLE_SAVEenvironment variable.
Note
Must be called from a Python script file, not an interactive shell.
Set the environment variable
SYSPLOT_DISABLE_SAVE=1(or any non-empty value) to skip all saves without modifying user code. This is useful for CI runs or test environments where writing output files is undesirable.Examples using
sysplot.save_current_figure#