From 34f8b8d90f3ef99d1ea783776e7daefd5e90b3aa Mon Sep 17 00:00:00 2001 From: Xue-Jian Jiang Date: Thu, 3 Sep 2020 11:29:47 -1000 Subject: [PATCH 1/3] Update spectral_cube.py add three parameters for plot_channel_maps so that one can plot and adjust a color bar for the channel maps. --- spectral_cube/spectral_cube.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spectral_cube/spectral_cube.py b/spectral_cube/spectral_cube.py index e4c66cbee..92888948d 100644 --- a/spectral_cube/spectral_cube.py +++ b/spectral_cube/spectral_cube.py @@ -3299,6 +3299,7 @@ def plot_channel_maps(self, nx, ny, channels, contourkwargs={}, output_file=None fig=None, fig_smallest_dim_inches=8, decimals=3, zoom=1, textcolor=None, cmap='gray_r', tighten=False, textxloc=0.5, textyloc=0.9, + colorbar=False, colorbar_title='', cax=[0.93, 0.08, 0.02, 0.4], savefig_kwargs={}, **kwargs): """ Make channel maps from a spectral cube @@ -3337,6 +3338,13 @@ def plot_channel_maps(self, nx, ny, channels, contourkwargs={}, output_file=None pointing center will be customizable. tighten : bool Call ``plt.tight_layout()`` after plotting? + colorbar : bool + plot a colorbar next the t + colorbar_title : str + title of the colorbar, default is empty. + cax : list + a box controling the position of the colorbar, in the format of + [left, bottom, width, height]. default value = [0.93, 0.08, 0.02, 0.4] savefig_kwargs : dict Keyword arguments to pass to ``savefig`` (e.g., ``bbox_inches='tight'``) @@ -3415,6 +3423,12 @@ def plot_channel_maps(self, nx, ny, channels, contourkwargs={}, output_file=None axis_list.append(ax) + if colorbar: + cax = plt.axes(cax) + fig = plt.gcf() + cbar = fig.colorbar(im, cax=cax) + cbar.ax.set_title(colorbar_title) + if tighten: plt.tight_layout() From c47aadb8c3a017293804e8c13ae2b181a7684dce Mon Sep 17 00:00:00 2001 From: Xue-Jian Jiang Date: Mon, 18 Apr 2022 23:13:57 -1000 Subject: [PATCH 2/3] Update spectral_cube/spectral_cube.py Co-authored-by: Adam Ginsburg --- spectral_cube/spectral_cube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectral_cube/spectral_cube.py b/spectral_cube/spectral_cube.py index 92888948d..3555b60df 100644 --- a/spectral_cube/spectral_cube.py +++ b/spectral_cube/spectral_cube.py @@ -3339,7 +3339,7 @@ def plot_channel_maps(self, nx, ny, channels, contourkwargs={}, output_file=None tighten : bool Call ``plt.tight_layout()`` after plotting? colorbar : bool - plot a colorbar next the t + plot a colorbar colorbar_title : str title of the colorbar, default is empty. cax : list From b6c0bed708bb4605513927fc5a577407239d2f99 Mon Sep 17 00:00:00 2001 From: Xue-Jian Jiang Date: Mon, 18 Apr 2022 23:14:07 -1000 Subject: [PATCH 3/3] Update spectral_cube/spectral_cube.py Co-authored-by: Adam Ginsburg --- spectral_cube/spectral_cube.py | 1 - 1 file changed, 1 deletion(-) diff --git a/spectral_cube/spectral_cube.py b/spectral_cube/spectral_cube.py index 3555b60df..f84c89f96 100644 --- a/spectral_cube/spectral_cube.py +++ b/spectral_cube/spectral_cube.py @@ -3425,7 +3425,6 @@ def plot_channel_maps(self, nx, ny, channels, contourkwargs={}, output_file=None if colorbar: cax = plt.axes(cax) - fig = plt.gcf() cbar = fig.colorbar(im, cax=cax) cbar.ax.set_title(colorbar_title)