From 81c01b27d625cfe858332373e884fc8cd5f0adcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCdepohl?= Date: Fri, 17 Apr 2020 21:36:45 +0200 Subject: [PATCH] Fix handling single contour level out of data range Previously, the behavior of ContourSet was special when a single contour level was specified that was out of range of the given z array. In that case, instead of the given value the minimum of the dataset was contoured, instead. This is very unexpected, in my opinion. This simple change simply makes no contour line at all, instead. --- lib/matplotlib/contour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 40a1d2b0f62d..dd12d490cb93 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -1161,7 +1161,7 @@ def _process_contour_level_args(self, args): inside = (self.levels > self.zmin) & (self.levels < self.zmax) levels_in = self.levels[inside] if len(levels_in) == 0: - self.levels = [self.zmin] + self.levels = [np.nan] cbook._warn_external( "No contour levels were found within the data range.")