Skip to content

Commit 174a5c9

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

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 7 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.texts = []
12351234
self.tables = []
12361235
self.artists = []
12371236
self.images = []
@@ -1317,6 +1316,10 @@ def patches(self):
13171316
return tuple(a for a in self._children
13181317
if isinstance(a, mpatches.Patch))
13191318

1319+
@property
1320+
def texts(self):
1321+
return tuple(a for a in self._children if isinstance(a, mtext.Text))
1322+
13201323
def clear(self):
13211324
"""Clear the axes."""
13221325
self.cla()
@@ -2122,11 +2125,11 @@ def add_line(self, line):
21222125

21232126
def _add_text(self, txt):
21242127
"""
2125-
Add a `~.Text` to the axes' texts; return the text.
2128+
Add a `~.Text` to the Axes; return the text.
21262129
"""
21272130
self._set_artist_props(txt)
2128-
self.texts.append(txt)
2129-
txt._remove_method = self.texts.remove
2131+
self._children.append(txt)
2132+
txt._remove_method = self._children.remove
21302133
self.stale = True
21312134
return txt
21322135

@@ -4336,7 +4339,6 @@ def get_children(self):
43364339
return [
43374340
*self.collections,
43384341
*self._children,
4339-
*self.texts,
43404342
*self.artists,
43414343
*self.spines.values(),
43424344
*self._get_axis_list(),

0 commit comments

Comments
 (0)