From 9d1c3cb5d7fba68c0dc675dd80825cac8b644e01 Mon Sep 17 00:00:00 2001
From: Keewis <keewis@posteo.de>
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 5510cf7f21..57cdf9f45d 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 <keewis@posteo.de>
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 57cdf9f45d..a83bc28e27 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: