@@ -39,12 +39,21 @@ class Cell(Rectangle):
39
39
PAD = 0.1
40
40
"""Padding between text and rectangle."""
41
41
42
+ _edges = 'BRTL'
43
+ _edge_aliases = {'open' :'' ,
44
+ 'closed' :_edges ,# default
45
+ 'horizontal' :'BT' ,
46
+ 'vertical' :'RL'
47
+ }
48
+
42
49
def __init__ (self ,xy ,width ,height ,
43
50
edgecolor = 'k' ,facecolor = 'w' ,
44
51
fill = True ,
45
52
text = '' ,
46
53
loc = None ,
47
- fontproperties = None
54
+ fontproperties = None ,
55
+ * ,
56
+ visible_edges = 'closed' ,
48
57
):
49
58
"""
50
59
Parameters
@@ -68,12 +77,18 @@ def __init__(self, xy, width, height,
68
77
fontproperties : dict
69
78
A dict defining the font properties of the text. Supported keys and
70
79
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).
71
85
"""
72
86
73
87
# Call base
74
88
Rectangle .__init__ (self ,xy ,width = width ,height = height ,fill = fill ,
75
89
edgecolor = edgecolor ,facecolor = facecolor )
76
90
self .set_clip_on (False )
91
+ self .visible_edges = visible_edges
77
92
78
93
# Create text object
79
94
if loc is None :
@@ -167,23 +182,6 @@ def set_text_props(self, **kwargs):
167
182
self ._text .update (kwargs )
168
183
self .stale = True
169
184
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
-
187
185
@property
188
186
def visible_edges (self ):
189
187
"""
@@ -228,6 +226,9 @@ def get_path(self):
228
226
)
229
227
230
228
229
+ CustomCell = Cell # Backcompat. alias.
230
+
231
+
231
232
class Table (Artist ):
232
233
"""
233
234
A table of cells.
@@ -331,20 +332,20 @@ def add_cell(self, row, col, *args, **kwargs):
331
332
332
333
Returns
333
334
-------
334
- `.CustomCell `
335
+ `.Cell `
335
336
The created cell.
336
337
337
338
"""
338
339
xy = (0 ,0 )
339
- cell = CustomCell (xy ,visible_edges = self .edges ,* args ,** kwargs )
340
+ cell = Cell (xy ,visible_edges = self .edges ,* args ,** kwargs )
340
341
self [row ,col ]= cell
341
342
return cell
342
343
343
344
def __setitem__ (self ,position ,cell ):
344
345
"""
345
346
Set a custom cell in a given position.
346
347
"""
347
- cbook ._check_isinstance (CustomCell ,cell = cell )
348
+ cbook ._check_isinstance (Cell ,cell = cell )
348
349
try :
349
350
row ,col = position [0 ],position [1 ]
350
351
except Exception as err :
@@ -363,7 +364,7 @@ def __getitem__(self, position):
363
364
@property
364
365
def edges (self ):
365
366
"""
366
- The default value of `~.CustomCell .visible_edges` for newly added
367
+ The default value of `~.Cell .visible_edges` for newly added
367
368
cells using `.add_cell`.
368
369
369
370
Notes
@@ -713,7 +714,7 @@ def table(ax,
713
714
714
715
edges : substring of 'BRTL' or {'open', 'closed', 'horizontal', 'vertical'}
715
716
The cell edges to be drawn with a line. See also
716
- `~.CustomCell .visible_edges`.
717
+ `~.Cell .visible_edges`.
717
718
718
719
Returns
719
720
-------