From 92a3fc4b09ff9a215869b6ba9e3b996e6d9ada04 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 22 Jun 2021 10:23:01 +0200 Subject: [PATCH] Deprecate Colorbar.patch. It is not used at all anymore (its vertices are not even set correctly) since the switch to ColorbarAxes. --- doc/api/next_api_changes/behavior/20054-JMK.rst | 5 +++++ lib/matplotlib/colorbar.py | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/api/next_api_changes/behavior/20054-JMK.rst b/doc/api/next_api_changes/behavior/20054-JMK.rst index d27ce486c8bb..0b9fb193df64 100644 --- a/doc/api/next_api_changes/behavior/20054-JMK.rst +++ b/doc/api/next_api_changes/behavior/20054-JMK.rst @@ -5,3 +5,8 @@ If a colorbar has lines added to it (e.g. for contour lines), these will no longer be clipped. This is an improvement for lines on the edge of the colorbar, but could lead to lines off the colorbar if the limits of the colorbar are changed. + +``Colorbar.patch`` is deprecated +================================ + +This attribute is not correctly updated anymore. diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 6285f412053c..2e0aa0ad3c93 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -451,10 +451,11 @@ def __init__(self, ax, mappable=None, *, cmap=None, spine.set_visible(False) self.outline = self.ax.spines['outline'] = _ColorbarSpine(self.ax) self._short_axis().set_visible(False) - self.patch = mpatches.Polygon( + # Only kept for backcompat; remove after deprecation of .patch elapses. + self._patch = mpatches.Polygon( np.empty((0, 2)), color=mpl.rcParams['axes.facecolor'], linewidth=0.01, zorder=-1) - ax.add_artist(self.patch) + ax.add_artist(self._patch) self.dividers = collections.LineCollection( [], @@ -487,6 +488,9 @@ def __init__(self, ax, mappable=None, *, cmap=None, if isinstance(mappable, contour.ContourSet) and not mappable.filled: self.add_lines(mappable) + # Also remove ._patch after deprecation elapses. + patch = _api.deprecate_privatize_attribute("3.5") + def update_normal(self, mappable): """ Update solid patches, lines, etc.