Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a8a7db

Browse files
authored
Merge pull request #10805 from tacaswell/fix_properties
FIX: properties and setp on Table instances
2 parents 6511253 + 1d22714 commit 0a8a7db

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
@@ -1075,11 +1075,11 @@ def __init__(self, o):
10751075
:class:`Artists` are of the same type) and it is your responsibility
10761076
to make sure this is so.
10771077
"""
1078-
if cbook.iterable(o):
1079-
# Wrapped in list instead of doing try-except around next(iter(o))
1080-
o = list(o)
1081-
if len(o):
1082-
o = o[0]
1078+
if not isinstance(o, Artist):
1079+
if cbook.iterable(o):
1080+
o = list(o)
1081+
if len(o):
1082+
o = o[0]
10831083

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

1439-
if not cbook.iterable(obj):
1439+
if isinstance(obj, Artist):
14401440
objs = [obj]
14411441
else:
14421442
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)