gemseo.utils.matplotlib_figure module#

Services for handling Matplotlib figures, e.g. save and show.

FigSizeType#

The type of a figure size.

save_show_figure(fig, show, file_path, fig_size=())[source]#

Save or show a Matplotlib figure.

Parameters:
  • fig (Figure) -- The Matplotlib figure to be saved or shown.

  • show (bool) -- Whether to display the Matplotlib figure.

  • file_path (str | Path) -- The file path to save the Matplotlib figure. If empty, do not save the figure.

  • fig_size (FigSizeType) --

    The width and height of the figure in inches, e.g. (w, h). If empty, use the current size of the figure.

    By default it is set to ().

Return type:

None

save_show_figure_from_file_path_manager(fig, file_path_manager, show=False, file_path='', directory_path='', file_name='', file_format='', fig_size=())[source]#

Save or show the plot.

Parameters:
  • fig (Figure) -- The figure to be processed.

  • file_path_manager (FilePathManager | None) -- A manager of file paths for a given type of file and with default settings. If None, do not save the figure.

  • show (bool) --

    Whether to show the figure.

    By default it is set to False.

  • file_path (str | Path) --

    The path of the file to save the figures. If empty, create a file path from directory_path, file_name and file_format.

    By default it is set to "".

  • directory_path (str | Path) --

    The path of the directory to save the figures. If empty, use the current working directory.

    By default it is set to "".

  • file_name (str) --

    The name of the file to save the figures. If empty, use a default one generated by the post-processing.

    By default it is set to "".

  • file_format (str) --

    A file format, e.g. 'png', 'pdf', 'svg', ... If empty, use a default file extension.

    By default it is set to "".

  • fig_size (FigSizeType) --

    The width and height of the figure in inches, e.g. (w, h). If empty, use the current size of the figure.

    By default it is set to ().

Returns:

The figure.

Return type:

Figure