From 4bb60f86b98a88f490a9e9d4088353c63c36b567 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 12 Dec 2021 09:19:15 +0100 Subject: [PATCH 1/2] MNT: deprecate filled parameter to colorbar The *filled* kwarg doesn't directly do anything and filling is completely controlled by the mappable. OTOH, maybe we want to reinstate the ability of *filled* to fill contours? --- lib/matplotlib/colorbar.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index b8da91c05109..d9029095adb4 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -370,6 +370,7 @@ class Colorbar: n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize + @_api.delete_parameter("3.6", "filled") def __init__(self, ax, mappable=None, *, cmap=None, norm=None, alpha=None, @@ -450,7 +451,7 @@ def __init__(self, ax, mappable=None, *, cmap=None, self.spacing = spacing self.orientation = orientation self.drawedges = drawedges - self.filled = filled + self._filled = filled self.extendfrac = extendfrac self.extendrect = extendrect self.solids = None @@ -530,6 +531,8 @@ def _cbar_cla(self): # Also remove ._patch after deprecation elapses. patch = _api.deprecate_privatize_attribute("3.5", alternative="ax") + filled = _api.deprecate_privatize_attribute("3.6") + def update_normal(self, mappable): """ Update solid patches, lines, etc. @@ -599,7 +602,7 @@ def draw_all(self): # boundary norms + uniform spacing requires a manual locator. self.update_ticks() - if self.filled: + if self._filled: ind = np.arange(len(self._values)) if self._extend_lower(): ind = ind[1:] @@ -671,7 +674,7 @@ def _do_extends(self, extendlen): # xyout is the path for the spine: self.outline.set_xy(xyout) - if not self.filled: + if not self._filled: return # Make extend triangles or rectangles filled patches. These are From 10b3de95f6f387c1656bccd9d4751c237f86349d Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 12 Dec 2021 09:25:28 +0100 Subject: [PATCH 2/2] Deprecate colorbar.draw_all. --- lib/matplotlib/colorbar.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index d9029095adb4..cffbb85dbd62 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -500,7 +500,7 @@ def __init__(self, ax, mappable=None, *, cmap=None, self.formatter = ticker.StrMethodFormatter(format) else: self.formatter = format # Assume it is a Formatter or None - self.draw_all() + self._draw_all() if isinstance(mappable, contour.ContourSet) and not mappable.filled: self.add_lines(mappable) @@ -554,14 +554,22 @@ def update_normal(self, mappable): self.norm = mappable.norm self._reset_locator_formatter_scale() - self.draw_all() + self._draw_all() if isinstance(self.mappable, contour.ContourSet): CS = self.mappable if not CS.filled: self.add_lines(CS) self.stale = True + @_api.deprecated("3.6", alternative="fig.draw_without_rendering()") def draw_all(self): + """ + Calculate any free parameters based on the current cmap and norm, + and do all the drawing. + """ + self._draw_all() + + def _draw_all(self): """ Calculate any free parameters based on the current cmap and norm, and do all the drawing.