From 0a288a2c908beb3e3f87cd0f7c5e89712b08a991 Mon Sep 17 00:00:00 2001 From: veenstrajelmer <60435591+veenstrajelmer@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:27:56 +0100 Subject: [PATCH] Update utils.py Proposing update to fix https://github.com/pydata/xarray/issues/7014 --- xarray/plot/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xarray/plot/utils.py b/xarray/plot/utils.py index b5d5a122c7a..158e74014f8 100644 --- a/xarray/plot/utils.py +++ b/xarray/plot/utils.py @@ -304,9 +304,11 @@ def _determine_cmap_params( if extend is None: extend = _determine_extend(calc_data, vmin, vmax) - if levels is not None or isinstance(norm, mpl.colors.BoundaryNorm): + if levels is not None: cmap, newnorm = _build_discrete_cmap(cmap, levels, extend, filled) norm = newnorm if norm is None else norm + if isinstance(norm, mpl.colors.BoundaryNorm): + cmap, norm = _build_discrete_cmap(cmap, levels, extend, filled) # vmin & vmax needs to be None if norm is passed # TODO: always return a norm with vmin and vmax