From a30dd94b436dc1fcdec46ca27dc3ea58200a85a6 Mon Sep 17 00:00:00 2001 From: "ashiqguntupalli@gmail.com" Date: Fri, 21 Feb 2025 22:46:28 +0100 Subject: [PATCH] feat: Added show and path to show map method in image object Added parameters to control plot behavior: - [show]: Toggle plot display - `path`: Save plot to file --- src/spectramap/spectramap.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/spectramap/spectramap.py b/src/spectramap/spectramap.py index a2136dc..c84f6ef 100644 --- a/src/spectramap/spectramap.py +++ b/src/spectramap/spectramap.py @@ -859,7 +859,7 @@ def vector_normalization(self): """ self.data = self.data/np.linalg.norm(self.data, axis=1)[:, None] - def show_map(self, xlabel='x', ylabel='y', ybarlabel='Intensity', title='Map', order = 'F'): + def show_map(self, xlabel='x', ylabel='y', ybarlabel='Intensity', title='Map', order = 'F', path = None, show = True): label_map = self.label.reshape((self.num_stepsx, self.num_stepsy), order=order) plt.figure() @@ -874,7 +874,11 @@ def show_map(self, xlabel='x', ylabel='y', ybarlabel='Intensity', title='Map', o plt.legend() - plt.show() + if show: + plt.show() + + if path is not None: + plt.savefig(path) def get_data(self): return (self.data)