Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commite55e79b

Browse files
authored
Merge pull request#17032 from anntzer/ccell
Fold table.CustomCell into Cell.
2 parentsb306a8e +66fa8bb commite55e79b

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

‎doc/api/api_changes_3.3/behaviour.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,8 @@ The default method used to format `.Slider` values has been changed to use a
171171
values are displayed with an appropriate number of significant digits even if
172172
they are much smaller or much bigger than 1. To restore the old behavior,
173173
explicitly pass a "%1.2f" as the *valfmt* parameter to `.Slider`.
174+
175+
``table.CustomCell`` is now an alias for `.table.Cell`
176+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
177+
All the functionality of ``CustomCell`` has been moved to its base class
178+
`~.table.Cell`.

‎lib/matplotlib/table.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
iflocisNone:
@@ -167,23 +182,6 @@ def set_text_props(self, **kwargs):
167182
self._text.update(kwargs)
168183
self.stale=True
169184

170-
171-
classCustomCell(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
defvisible_edges(self):
189187
"""
@@ -228,6 +226,9 @@ def get_path(self):
228226
)
229227

230228

229+
CustomCell=Cell# Backcompat. alias.
230+
231+
231232
classTable(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
returncell
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
exceptExceptionaserr:
@@ -363,7 +364,7 @@ def __getitem__(self, position):
363364
@property
364365
defedges(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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp