diff --git a/xarray/plot/plot.py b/xarray/plot/plot.py index 79c4cf7cb6e..8699007ca81 100644 --- a/xarray/plot/plot.py +++ b/xarray/plot/plot.py @@ -445,8 +445,9 @@ def newplotfunc(darray, x=None, y=None, figsize=None, size=None, # Decide on a default for the colorbar before facetgrids if add_colorbar is None: add_colorbar = plotfunc.__name__ != 'contour' - imshow_rgb = plotfunc.__name__ == 'imshow' and \ - darray.ndim == (3 + (row is not None) + (col is not None)) + imshow_rgb = ( + plotfunc.__name__ == 'imshow' and + darray.ndim == (3 + (row is not None) + (col is not None))) if imshow_rgb: # Don't add a colorbar when showing an image with explicit colors add_colorbar = False @@ -696,7 +697,8 @@ def imshow(x, y, z, ax, **kwargs): # there isn't one, and set it to transparent where data is masked. if z.shape[-1] == 3: z = np.ma.concatenate((z, np.ma.ones(z.shape[:2] + (1,))), 2) - z[np.sum(z.mask, axis=-1, dtype=bool),-1] = 0 + z = z.copy() + z[np.any(z.mask, axis=-1), -1] = 0 primitive = ax.imshow(z, **defaults) diff --git a/xarray/plot/utils.py b/xarray/plot/utils.py index 0de94fd12a7..e476522f587 100644 --- a/xarray/plot/utils.py +++ b/xarray/plot/utils.py @@ -267,7 +267,9 @@ def _infer_xy_labels_3d(darray, x, y, rgb): assert darray.ndim == 3 not_none = [a for a in (x, y, rgb) if a is not None] if len(set(not_none)) < len(not_none): - raise ValueError('Dimensions passed as x, y, and rgb must be unique.') + raise ValueError( + 'Dimension names must be None or unique strings, but imshow was ' + 'passed x=%r, y=%r, and rgb=%r.' % (x, y, rgb)) for label in not_none: if label not in darray.dims: raise ValueError('%r is not a dimension' % (label,))