@@ -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 :
@@ -178,23 +193,6 @@ def set_text_props(self, **kwargs):
178
193
self ._text .update (kwargs )
179
194
self .stale = True
180
195
181
-
182
- class CustomCell (Cell ):
183
- """
184
- A `.Cell` subclass with configurable edge visibility.
185
- """
186
-
187
- _edges = 'BRTL'
188
- _edge_aliases = {'open' : '' ,
189
- 'closed' : _edges , # default
190
- 'horizontal' : 'BT' ,
191
- 'vertical' : 'RL'
192
- }
193
-
194
- def __init__ (self , * args , visible_edges , ** kwargs ):
195
- super ().__init__ (* args , ** kwargs )
196
- self .visible_edges = visible_edges
197
-
198
196
@property
199
197
def visible_edges (self ):
200
198
"""
@@ -239,6 +237,9 @@ def get_path(self):
239
237
)
240
238
241
239
240
+ CustomCell = Cell # Backcompat. alias.
241
+
242
+
242
243
class Table (Artist ):
243
244
"""
244
245
A table of cells.
@@ -342,20 +343,20 @@ def add_cell(self, row, col, *args, **kwargs):
342
343
343
344
Returns
344
345
-------
345
- `.CustomCell `
346
+ `.Cell `
346
347
The created cell.
347
348
348
349
"""
349
350
xy = (0 , 0 )
350
- cell = CustomCell (xy , visible_edges = self .edges , * args , ** kwargs )
351
+ cell = Cell (xy , visible_edges = self .edges , * args , ** kwargs )
351
352
self [row , col ] = cell
352
353
return cell
353
354
354
355
def __setitem__ (self , position , cell ):
355
356
"""
356
357
Set a custom cell in a given position.
357
358
"""
358
- cbook ._check_isinstance (CustomCell , cell = cell )
359
+ cbook ._check_isinstance (Cell , cell = cell )
359
360
try :
360
361
row , col = position [0 ], position [1 ]
361
362
except Exception as err :
@@ -374,7 +375,7 @@ def __getitem__(self, position):
374
375
@property
375
376
def edges (self ):
376
377
"""
377
- The default value of `~.CustomCell .visible_edges` for newly added
378
+ The default value of `~.Cell .visible_edges` for newly added
378
379
cells using `.add_cell`.
379
380
380
381
Notes
@@ -724,7 +725,7 @@ def table(ax,
724
725
725
726
edges : substring of 'BRTL' or {'open', 'closed', 'horizontal', 'vertical'}
726
727
The cell edges to be drawn with a line. See also
727
- `~.CustomCell .visible_edges`.
728
+ `~.Cell .visible_edges`.
728
729
729
730
Returns
730
731
-------
0 commit comments