Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jan 9, 2018
1 parent c12612d commit e2b5580
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions xarray/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion xarray/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand Down

0 comments on commit e2b5580

Please sign in to comment.