Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve plot_channel_maps by adding parameters for the usage of colorbar #662

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions spectral_cube/spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
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'``)
Expand Down Expand Up @@ -3415,6 +3423,11 @@ def plot_channel_maps(self, nx, ny, channels, contourkwargs={}, output_file=None

axis_list.append(ax)

if colorbar:
cax = plt.axes(cax)
cbar = fig.colorbar(im, cax=cax)
cbar.ax.set_title(colorbar_title)

if tighten:
plt.tight_layout()

Expand Down