Skip to content

Commit

Permalink
Merge pull request #182 from DanRyanIrish/plot_bugfix
Browse files Browse the repository at this point in the history
Fix bug in 2D plotting.
  • Loading branch information
DanRyanIrish committed Jul 10, 2019
1 parent a667760 commit af21f4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog/182.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix 2D plotting from crashing when both data and WCS are 2D.
12 changes: 7 additions & 5 deletions ndcube/mixins/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,25 @@ def _plot_2D_cube(self, axes=None, plot_axis_indices=None, axes_coordinates=None
data = np.ma.masked_array(data, self.mask)
if axes is None:
try:
axes_coord_check == [None, None]
axes_coord_check = axes_coordinates == [None, None]
except:
axes_coord_check = False
if axes_coord_check:
# Build slice list for WCS for initializing WCSAxes object.
if self.wcs.naxis is not 2:
if self.wcs.naxis != 2:
slice_list = []
index = 0
for i, bool_ in enumerate(self.missing_axis):
for bool_ in self.missing_axis:
if not bool_:
slice_list.append(axis_data[index])
index += 1
else:
slice_list.append(1)
if index is not 2:
if index != 2:
raise ValueError("Dimensions of WCS and data don't match")
ax = wcsaxes_compat.gca_wcs(self.wcs, slices=slice_list)
ax = wcsaxes_compat.gca_wcs(self.wcs, slices=tuple(slice_list))
else:
ax = wcsaxes_compat.gca_wcs(self.wcs)
# Set axis labels
x_wcs_axis = utils.cube.data_axis_to_wcs_axis(plot_axis_indices[0],
self.missing_axis)
Expand Down

0 comments on commit af21f4b

Please sign in to comment.