Skip to content

Commit 1b3f342

Browse files
committed
Simplify rgb-detection heuristic
1 parent e09b8a3 commit 1b3f342

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

xarray/plot/utils.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,12 @@ def _infer_xy_labels_3d(darray, x, y, rgb):
288288
# in could_be_color. We therefore warn, and use a heuristic to break ties.
289289
if rgb is None:
290290
assert len(could_be_color) in (2, 3)
291-
if darray.dims[-1] in could_be_color:
292-
rgb = darray.dims[-1]
293-
warnings.warn(
294-
'Several dimensions of this array could be colors. Xarray '
295-
'will use the last dimension (%r) to match '
296-
'matplotlib.pyplot.imshow. You can pass names of x, y, '
297-
'and/or rgb dimensions to override this guess.' % rgb)
298-
else:
299-
rgb = darray.dims[0]
300-
warnings.warn(
301-
'%r has been selected as the color dimension, but %r would '
302-
'also be valid. Pass names of x, y, and/or rgb dimensions to '
303-
'override this guess.' % darray.dims[:2])
291+
rgb = could_be_color[-1]
292+
warnings.warn(
293+
'Several dimensions of this array could be colors. Xarray '
294+
'will use the last possible dimension (%r) to match '
295+
'matplotlib.pyplot.imshow. You can pass names of x, y, '
296+
'and/or rgb dimensions to override this guess.' % rgb)
304297
assert rgb is not None
305298

306299
# Finally, we pick out the red slice and delegate to the 2D version:

0 commit comments

Comments
 (0)