Skip to content

Commit e2b5580

Browse files
committed
Address review comments
1 parent c12612d commit e2b5580

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

xarray/plot/plot.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,9 @@ def newplotfunc(darray, x=None, y=None, figsize=None, size=None,
445445
# Decide on a default for the colorbar before facetgrids
446446
if add_colorbar is None:
447447
add_colorbar = plotfunc.__name__ != 'contour'
448-
imshow_rgb = plotfunc.__name__ == 'imshow' and \
449-
darray.ndim == (3 + (row is not None) + (col is not None))
448+
imshow_rgb = (
449+
plotfunc.__name__ == 'imshow' and
450+
darray.ndim == (3 + (row is not None) + (col is not None)))
450451
if imshow_rgb:
451452
# Don't add a colorbar when showing an image with explicit colors
452453
add_colorbar = False
@@ -696,7 +697,8 @@ def imshow(x, y, z, ax, **kwargs):
696697
# there isn't one, and set it to transparent where data is masked.
697698
if z.shape[-1] == 3:
698699
z = np.ma.concatenate((z, np.ma.ones(z.shape[:2] + (1,))), 2)
699-
z[np.sum(z.mask, axis=-1, dtype=bool),-1] = 0
700+
z = z.copy()
701+
z[np.any(z.mask, axis=-1), -1] = 0
700702

701703
primitive = ax.imshow(z, **defaults)
702704

xarray/plot/utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ def _infer_xy_labels_3d(darray, x, y, rgb):
267267
assert darray.ndim == 3
268268
not_none = [a for a in (x, y, rgb) if a is not None]
269269
if len(set(not_none)) < len(not_none):
270-
raise ValueError('Dimensions passed as x, y, and rgb must be unique.')
270+
raise ValueError(
271+
'Dimension names must be None or unique strings, but imshow was '
272+
'passed x=%r, y=%r, and rgb=%r.' % (x, y, rgb))
271273
for label in not_none:
272274
if label not in darray.dims:
273275
raise ValueError('%r is not a dimension' % (label,))

0 commit comments

Comments
 (0)