Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 37651d6

Browse filesBrowse 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 d52a8c2 commit 37651d6
Copy full SHA for 37651d6

File tree

Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,6 @@ def cla(self):
11461146

11471147
self._gridOn = mpl.rcParams['axes.grid']
11481148
self._children = []
1149-
self.texts = []
11501149
self.tables = []
11511150
self.artists = []
11521151
self.images = []
@@ -1231,6 +1230,10 @@ def patches(self):
12311230
return tuple(a for a in self._children
12321231
if isinstance(a, mpatches.Patch))
12331232

1233+
@property
1234+
def texts(self):
1235+
return tuple(a for a in self._children if isinstance(a, mtext.Text))
1236+
12341237
def clear(self):
12351238
"""Clear the axes."""
12361239
self.cla()
@@ -2027,11 +2030,11 @@ def add_line(self, line):
20272030

20282031
def _add_text(self, txt):
20292032
"""
2030-
Add a `~.Text` to the axes' texts; return the text.
2033+
Add a `~.Text` to the Axes; return the text.
20312034
"""
20322035
self._set_artist_props(txt)
2033-
self.texts.append(txt)
2034-
txt._remove_method = self.texts.remove
2036+
self._children.append(txt)
2037+
txt._remove_method = self._children.remove
20352038
self.stale = True
20362039
return txt
20372040

@@ -4239,7 +4242,6 @@ def get_children(self):
42394242
return [
42404243
*self.collections,
42414244
*self._children,
4242-
*self.texts,
42434245
*self.artists,
42444246
*self.spines.values(),
42454247
*self._get_axis_list(),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.