From 9d1c3cb5d7fba68c0dc675dd80825cac8b644e01 Mon Sep 17 00:00:00 2001 From: Keewis Date: Sat, 6 Mar 2021 23:16:57 +0100 Subject: [PATCH 1/3] duplicate the level if a single level was passed --- xarray/plot/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xarray/plot/utils.py b/xarray/plot/utils.py index 5510cf7f219..57cdf9f45d6 100644 --- a/xarray/plot/utils.py +++ b/xarray/plot/utils.py @@ -60,6 +60,11 @@ def _build_discrete_cmap(cmap, levels, extend, filled): """ import matplotlib as mpl + if isinstance(levels, (int, float)): + levels = [levels, levels] + elif len(levels) == 1: + levels = [levels[0], levels[0]] + if not filled: # non-filled contour plots extend = "max" From 7977ce0fa25971abc50a5dd010d15d71f8013a84 Mon Sep 17 00:00:00 2001 From: Keewis Date: Sat, 6 Mar 2021 23:29:39 +0100 Subject: [PATCH 2/3] don't handle scalars it seems these will never be passed at that level --- xarray/plot/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/xarray/plot/utils.py b/xarray/plot/utils.py index 57cdf9f45d6..a83bc28e273 100644 --- a/xarray/plot/utils.py +++ b/xarray/plot/utils.py @@ -60,9 +60,7 @@ def _build_discrete_cmap(cmap, levels, extend, filled): """ import matplotlib as mpl - if isinstance(levels, (int, float)): - levels = [levels, levels] - elif len(levels) == 1: + if len(levels) == 1: levels = [levels[0], levels[0]] if not filled: From 01088e80b3557796209216556d87aa3d7acc310e Mon Sep 17 00:00:00 2001 From: Keewis Date: Sun, 7 Mar 2021 12:14:09 +0100 Subject: [PATCH 3/3] [test-upstream] [skip-ci]