From 736423503d30ef272464db1cb4c6ac197f193b2b Mon Sep 17 00:00:00 2001 From: rebeccajhampton Date: Sun, 2 Oct 2022 11:05:41 -0400 Subject: [PATCH] Handles yscaled with length 1 --- lib/matplotlib/colorbar.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index c8f49c0ad92d..7f1930484283 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -1243,10 +1243,14 @@ def _proportional_y(self): yscaled = np.ma.filled(norm(yscaled), np.nan) # make the lower and upper extend lengths proportional to the lengths # of the first and last boundary spacing (if extendfrac='auto'): - automin = yscaled[1] - yscaled[0] - automax = yscaled[-1] - yscaled[-2] extendlength = [0, 0] if self._extend_lower() or self._extend_upper(): + if len(yscaled) == 1: + automin = yscaled[0] + automax = yscaled[0] + else: + automin = yscaled[1] - yscaled[0] + automax = yscaled[-1] - yscaled[-2] extendlength = self._get_extension_lengths( self.extendfrac, automin, automax, default=0.05) return y, extendlength