Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate Colorbar.patch. #20481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/behavior/20054-JMK.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 6 additions & 2 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[],
Expand Down Expand Up @@ -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.
Expand Down