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