opendvp.io.export_figure

Contents

opendvp.io.export_figure#

opendvp.io.export_figure(fig, path_to_dir, suffix, dpi=300)#

Save a matplotlib figure as both PDF and SVG files with a timestamped filename.

The function creates the output directory if it does not exist, generates a timestamped filename using the current date and time, and saves the figure in both PDF and SVG formats with the specified DPI. For SVG export, it ensures that text remains editable in vector graphics editors like Adobe Illustrator.

Return type:

None

Parameters:#

figmatplotlib.figure.Figure

The matplotlib figure object to be saved.

path_to_dirstr

Directory path where the figure files will be saved.

suffixstr

A custom suffix to include in the filename (e.g., describing the content).

dpiint, optional

Resolution in dots per inch for the saved figure. Default is 300.

Returns:#

None

Prints:#

str

Confirmation message with the full paths to the saved PDF and SVG files.

Examples:#

>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> ax.plot([0, 1], [0, 1])
>>> export_figure(fig, path="figures/", suffix="line_plot")

Figures saved as: figures/20250519_1245_line_plot.pdf figures/20250519_1245_line_plot.svg