Skip to content

Commit 20198b8

Browse files
committed
Move Axes.patches into hidden children attribute.
The patches can still be accessed via a read-only property, but now are combined with lines for sorting and overall drawing purposes.
1 parent af6fce7 commit 20198b8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,6 @@ def cla(self):
12311231

12321232
self._gridOn = mpl.rcParams['axes.grid']
12331233
self._children = []
1234-
self.patches = []
12351234
self.texts = []
12361235
self.tables = []
12371236
self.artists = []
@@ -1313,6 +1312,11 @@ def cla(self):
13131312
def lines(self):
13141313
return tuple(a for a in self._children if isinstance(a, mlines.Line2D))
13151314

1315+
@property
1316+
def patches(self):
1317+
return tuple(a for a in self._children
1318+
if isinstance(a, mpatches.Patch))
1319+
13161320
def clear(self):
13171321
"""Clear the axes."""
13181322
self.cla()
@@ -2172,14 +2176,14 @@ def _update_line_limits(self, line):
21722176

21732177
def add_patch(self, p):
21742178
"""
2175-
Add a `~.Patch` to the axes' patches; return the patch.
2179+
Add a `~.Patch` to the Axes; return the patch.
21762180
"""
21772181
self._set_artist_props(p)
21782182
if p.get_clip_path() is None:
21792183
p.set_clip_path(self.patch)
21802184
self._update_patch_limits(p)
2181-
self.patches.append(p)
2182-
p._remove_method = self.patches.remove
2185+
self._children.append(p)
2186+
p._remove_method = self._children.remove
21832187
return p
21842188

21852189
def _update_patch_limits(self, patch):
@@ -4331,7 +4335,6 @@ def get_children(self):
43314335
# docstring inherited.
43324336
return [
43334337
*self.collections,
4334-
*self.patches,
43354338
*self._children,
43364339
*self.texts,
43374340
*self.artists,

0 commit comments

Comments
 (0)