From e0da354de6fe42bbbbd328e866e2c56710c645b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Soares?= Date: Thu, 24 Oct 2024 12:58:40 +0100 Subject: [PATCH] Implementation of returnable plot objects --- src/spinplots/plot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/spinplots/plot.py b/src/spinplots/plot.py index 90c3cb4..c337487 100644 --- a/src/spinplots/plot.py +++ b/src/spinplots/plot.py @@ -88,6 +88,7 @@ def bruker2d(data_path, contour_start, contour_num, contour_factor, cmap=None, x if ylim: ax['A'].set_ylim(ylim) ax['b'].set_ylim(ylim) + # Show the plot or save it if save: @@ -99,6 +100,8 @@ def bruker2d(data_path, contour_start, contour_num, contour_factor, cmap=None, x else: plt.show() + return ax + # Function to easily plot 1D NMR spectra in Bruker's format def bruker1d(data_paths, labels=None, xlim=None, save=False, filename=None, format=None, frame=False, normalized=False, stacked=False): @@ -190,6 +193,8 @@ def bruker1d(data_paths, labels=None, xlim=None, save=False, filename=None, form else: fig.show() + return fig, ax + # Function to easily plot 1D NMR spectra in Bruker's format in a grid def bruker1d_grid(data_paths, labels=None, subplot_dims=(1, 1), xlim=None, save=False, filename=None, format='png', frame=False, normalized=False): """ @@ -258,3 +263,5 @@ def bruker1d_grid(data_paths, labels=None, subplot_dims=(1, 1), xlim=None, save= fig.savefig(full_filename, format=format, dpi=300, bbox_inches='tight', pad_inches=0.1) else: fig.show() + + return fig, axes