diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index cfb19bf95001..7f529af5f24d 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -1231,10 +1231,11 @@ def _process_levels(self): self.layers = 0.5 * (self._levels[:-1] + self._levels[1:]) # ...except that extended layers must be outside the # normed range: + finfo = np.finfo(float) if self.extend in ('both', 'min'): - self.layers[0] = -np.inf + self.layers[0] = self.vmin - finfo.eps if self.extend in ('both', 'max'): - self.layers[-1] = np.inf + self.layers[-1] = self.vmax + finfo.eps def _process_colors(self): """