Skip to content

Commit 71f5775

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

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
@@ -23,6 +23,7 @@
2323
import matplotlib.axis as maxis
2424
import matplotlib.spines as mspines
2525
import matplotlib.font_manager as font_manager
26+
import matplotlib.table as mtable
2627
import matplotlib.text as mtext
2728
import matplotlib.image as mimage
2829
import matplotlib.path as mpath
@@ -1231,7 +1232,6 @@ def cla(self):
12311232

12321233
self._gridOn = mpl.rcParams['axes.grid']
12331234
self._children = []
1234-
self.tables = []
12351235
self.artists = []
12361236
self.images = []
12371237
self._mouseover_set = _OrderedSet()
@@ -1316,6 +1316,10 @@ def patches(self):
13161316
return tuple(a for a in self._children
13171317
if isinstance(a, mpatches.Patch))
13181318

1319+
@property
1320+
def tables(self):
1321+
return tuple(a for a in self._children if isinstance(a, mtable.Table))
1322+
13191323
@property
13201324
def texts(self):
13211325
return tuple(a for a in self._children if isinstance(a, mtext.Text))
@@ -2219,12 +2223,12 @@ def _update_patch_limits(self, patch):
22192223

22202224
def add_table(self, tab):
22212225
"""
2222-
Add a `~.Table` to the axes' tables; return the table.
2226+
Add a `~.Table` to the Axes; return the table.
22232227
"""
22242228
self._set_artist_props(tab)
2225-
self.tables.append(tab)
2229+
self._children.append(tab)
22262230
tab.set_clip_path(self.patch)
2227-
tab._remove_method = self.tables.remove
2231+
tab._remove_method = self._children.remove
22282232
return tab
22292233

22302234
def add_container(self, container):
@@ -4343,7 +4347,6 @@ def get_children(self):
43434347
*self.spines.values(),
43444348
*self._get_axis_list(),
43454349
self.title, self._left_title, self._right_title,
4346-
*self.tables,
43474350
*self.images,
43484351
*self.child_axes,
43494352
*([self.legend_] if self.legend_ is not None else []),

0 commit comments

Comments
 (0)