10000 Backport PR #10805: FIX: properties and setp on Table instances · matplotlib/matplotlib@bc4db69 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc4db69

Browse files
phobsonMeeseeksDev[bot]
authored andcommitted
Backport PR #10805: FIX: properties and setp on Table instances
1 parent fb6e599 commit bc4db69

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/matplotlib/artist.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,11 @@ def __init__(self, o):
10761076
:class:`Artists` are of the same type) and it is your responsibility
10771077
to make sure this is so.
10781078
"""
1079-
if cbook.iterable(o):
1080-
# Wrapped in list instead of doing try-except around next(iter(o))
1081-
o = list(o)
1082-
if len(o):
1083-
o = o[0]
1079+
if not isinstance(o, Artist):
1080+
if cbook.iterable(o):
1081+
o = list(o)
1082+
if len(o):
1083+
o = o[0]
10841084

10851085
self.oorig = o
10861086
if not inspect.isclass(o):
@@ -1437,7 +1437,7 @@ def setp(obj, *args, **kwargs):
14371437
>>> setp(lines, linewidth=2, color='r') # python style
14381438
"""
14391439

1440-
if not cbook.iterable(obj):
1440+
if isinstance(obj, Artist):
14411441
objs = [obj]
14421442
else:
14431443
objs = list(cbook.flatten(obj))

lib/matplotlib/tests/test_table.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,8 @@ def test_table_cells():
194194
cell2 = CustomCell((0, 0), 1, 2, visible_edges=None)
195195
table[2, 1] = cell2
196196
assert table[2, 1] is cell2
197+
198+
# make sure gettitem support has not broken
199+
# properties and setp
200+
table.properties()
201+
plt.setp(table)

0 commit comments

Comments
 (0)
0