diff --git a/changelog/278.bugfix.rst b/changelog/278.bugfix.rst new file mode 100644 index 000000000..f9a739318 --- /dev/null +++ b/changelog/278.bugfix.rst @@ -0,0 +1 @@ +Fix NDCube plotting bug when dependent axes are not first axes. diff --git a/ndcube/mixins/plotting.py b/ndcube/mixins/plotting.py index 2dea566ab..c0e2e7e6c 100644 --- a/ndcube/mixins/plotting.py +++ b/ndcube/mixins/plotting.py @@ -452,10 +452,10 @@ def _derive_axes_coordinates(self, axes_coordinates, axes_units, data_shape, edg axis_label_text = self.world_axis_physical_types[i] # If the shape of the data is not 1, or all the axes are not dependent if new_axis_coordinate.ndim != 1 and new_axis_coordinate.ndim != len(data_shape): - index = utils.wcs.get_dependent_data_axes(self.wcs, i, self.missing_axes) - reduce_axis = np.where(index == np.array([i]))[0] - - index = np.delete(index, reduce_axis) + dependent_axes = utils.wcs.get_dependent_data_axes(self.wcs, i, + self.missing_axes) + reduce_axis = np.where(dependent_axes == np.array([i]))[0] + index = np.delete(np.arange(len(dependent_axes)), reduce_axis) # Reduce the data by taking mean new_axis_coordinate = np.mean(new_axis_coordinate, axis=tuple(index))