@@ -39,12 +39,21 @@ class Cell(Rectangle):
3939 PAD = 0.1
4040 """Padding between text and rectangle."""
4141
42+ _edges = 'BRTL'
43+ _edge_aliases = {'open' : '' ,
44+ 'closed' : _edges , # default
45+ 'horizontal' : 'BT' ,
46+ 'vertical' : 'RL'
47+ }
48+
4249 def __init__ (self , xy , width , height ,
4350 edgecolor = 'k' , facecolor = 'w' ,
4451 fill = True ,
4552 text = '' ,
4653 loc = None ,
47- fontproperties = None
54+ fontproperties = None ,
55+ * ,
56+ visible_edges = 'closed' ,
4857 ):
4958 """
5059 Parameters
@@ -68,12 +77,18 @@ def __init__(self, xy, width, height,
6877 fontproperties : dict
6978 A dict defining the font properties of the text. Supported keys and
7079 values are the keyword arguments accepted by `.FontProperties`.
80+ visible_edges : str, default: 'closed'
81+ The cell edges to be drawn with a line: a substring of 'BRTL'
82+ (bottom, right, top, left), or one of 'open' (no edges drawn),
83+ 'closed' (all edges drawn), 'horizontal' (bottom and top),
84+ 'vertical' (right and left).
7185 """
7286
7387 # Call base
7488 Rectangle .__init__ (self , xy , width = width , height = height , fill = fill ,
7589 edgecolor = edgecolor , facecolor = facecolor )
7690 self .set_clip_on (False )
91+ self .visible_edges = visible_edges
7792
7893 # Create text object
7994 if loc is None :
@@ -167,23 +182,6 @@ def set_text_props(self, **kwargs):
167182 self ._text .update (kwargs )
168183 self .stale = True
169184
170-
171- class CustomCell (Cell ):
172- """
173- A `.Cell` subclass with configurable edge visibility.
174- """
175-
176- _edges = 'BRTL'
177- _edge_aliases = {'open' : '' ,
178- 'closed' : _edges , # default
179- 'horizontal' : 'BT' ,
180- 'vertical' : 'RL'
181- }
182-
183- def __init__ (self , * args , visible_edges , ** kwargs ):
184- super ().__init__ (* args , ** kwargs )
185- self .visible_edges = visible_edges
186-
187185 @property
188186 def visible_edges (self ):
189187 """
@@ -228,6 +226,9 @@ def get_path(self):
228226 )
229227
230228
229+ CustomCell = Cell # Backcompat. alias.
230+
231+
231232class Table (Artist ):
232233 """
233234 A table of cells.
@@ -331,20 +332,20 @@ def add_cell(self, row, col, *args, **kwargs):
331332
332333 Returns
333334 -------
334- `.CustomCell `
335+ `.Cell `
335336 The created cell.
336337
337338 """
338339 xy = (0 , 0 )
339- cell = CustomCell (xy , visible_edges = self .edges , * args , ** kwargs )
340+ cell = Cell (xy , visible_edges = self .edges , * args , ** kwargs )
340341 self [row , col ] = cell
341342 return cell
342343
343344 def __setitem__ (self , position , cell ):
344345 """
345346 Set a custom cell in a given position.
346347 """
347- cbook ._check_isinstance (CustomCell , cell = cell )
348+ cbook ._check_isinstance (Cell , cell = cell )
348349 try :
349350 row , col = position [0 ], position [1 ]
350351 except Exception as err :
@@ -363,7 +364,7 @@ def __getitem__(self, position):
363364 @property
364365 def edges (self ):
365366 """
366- The default value of `~.CustomCell .visible_edges` for newly added
367+ The default value of `~.Cell .visible_edges` for newly added
367368 cells using `.add_cell`.
368369
369370 Notes
@@ -713,7 +714,7 @@ def table(ax,
713714
714715 edges : substring of 'BRTL' or {'open', 'closed', 'horizontal', 'vertical'}
715716 The cell edges to be drawn with a line. See also
716- `~.CustomCell .visible_edges`.
717+ `~.Cell .visible_edges`.
717718
718719 Returns
719720 -------
0 commit comments