From ce385fe4464b3ffc866fe2faf8d44e14d0c8f0c6 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Fri, 25 Aug 2023 10:33:11 -0500 Subject: [PATCH 1/2] Avoid checking limits when updating both min and max for contours closes #26531 --- lib/matplotlib/contour.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 79f66b896131..aa3041ddce9b 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -887,11 +887,12 @@ def __init__(self, ax, *args, self.set_cmap(cmap) if norm is not None: self.set_norm(norm) - if vmin is not None: - self.norm.vmin = vmin - if vmax is not None: - self.norm.vmax = vmax - self._process_colors() + with self.norm.callbacks.blocked(signal="changed"): + if vmin is not None: + self.norm.vmin = vmin + if vmax is not None: + self.norm.vmax = vmax + self._process_colors() if self._paths is None: self._paths = self._make_paths_from_contour_generator() From e908ac1344fd90f72fe7a43962db61bec170abfc Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Tue, 5 Sep 2023 12:11:20 -0500 Subject: [PATCH 2/2] Add changed callback after setting norm values --- lib/matplotlib/contour.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index aa3041ddce9b..7de45b54de38 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -892,7 +892,8 @@ def __init__(self, ax, *args, self.norm.vmin = vmin if vmax is not None: self.norm.vmax = vmax - self._process_colors() + self.norm._changed() + self._process_colors() if self._paths is None: self._paths = self._make_paths_from_contour_generator()