Skip to content

Commit

Permalink
Merge pull request #6 from carlosbornes/feature/returnable
Browse files Browse the repository at this point in the history
Implementation of returnable plot objects
  • Loading branch information
MSoares98 authored Oct 24, 2024
2 parents f40c6af + 9708bb3 commit 52ea97e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/spinplots/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -99,6 +100,7 @@ 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, color=None):
Expand Down Expand Up @@ -196,6 +198,8 @@ def bruker1d(data_paths, labels=None, xlim=None, save=False, filename=None, form
else:
plt.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, color=None):
"""
Expand Down Expand Up @@ -269,4 +273,6 @@ def bruker1d_grid(data_paths, labels=None, subplot_dims=(1, 1), xlim=None, save=
full_filename = "1d_nmr_spectra." + format
fig.savefig(full_filename, format=format, dpi=300, bbox_inches='tight', pad_inches=0.1)
else:
plt.show()
fig.show()

return fig, axes

0 comments on commit 52ea97e

Please sign in to comment.