simkit.filesystem.save_figure#

Functions#

save_figure(fig, path[, copy_to, dpi, bbox_inches])

Save a Matplotlib figure, creating folders, and optionally copy it elsewhere.

Module Contents#

simkit.filesystem.save_figure.save_figure(fig, path, copy_to=None, dpi=150, bbox_inches='tight', **savefig_kwargs)#

Save a Matplotlib figure, creating folders, and optionally copy it elsewhere.

Parameters:
  • fig (matplotlib.figure.Figure) – Figure to save.

  • path (str) – Output image path (format from the extension, e.g. .png).

  • copy_to (str or list of str, optional) – Extra destinations (file paths, or existing directories to copy into under the same basename). Used to mirror notebook media into media/.

  • dpi (int, optional) – Resolution. Defaults to 150.

  • bbox_inches (str, optional) – Passed to savefig. Defaults to "tight".

  • **savefig_kwargs – Forwarded to fig.savefig.

Returns:

path – The primary saved path.

Return type:

str