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 to savefig_folder.

  • fmt (str | None) – File format (e.g., "pdf", "svg", "png"). Defaults to figure_fmt.

  • transparent (bool | None) – Whether to save with a transparent background. Defaults to savefig_transparent.

Return type:

Path | None

Returns:

Path of the saved file, or None if saving is disabled via the SYSPLOT_DISABLE_SAVE environment 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#

Save Current Figure

Save Current Figure