From 1d22714fb770cda7c914254c75c3aeecbfa6e280 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 15 Mar 2018 21:09:18 -0400 Subject: [PATCH] FIX: properties and setp on Table instances closes #10732 --- lib/matplotlib/artist.py | 12 ++++++------ lib/matplotlib/tests/test_table.py | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index d64e2dd5e3f9..d99323d0608e 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -1075,11 +1075,11 @@ def __init__(self, o): :class:`Artists` are of the same type) and it is your responsibility to make sure this is so. """ - if cbook.iterable(o): - # Wrapped in list instead of doing try-except around next(iter(o)) - o = list(o) - if len(o): - o = o[0] + if not isinstance(o, Artist): + if cbook.iterable(o): + o = list(o) + if len(o): + o = o[0] self.oorig = o if not inspect.isclass(o): @@ -1436,7 +1436,7 @@ def setp(obj, *args, **kwargs): >>> setp(lines, linewidth=2, color='r') # python style """ - if not cbook.iterable(obj): + if isinstance(obj, Artist): objs = [obj] else: objs = list(cbook.flatten(obj)) diff --git a/lib/matplotlib/tests/test_table.py b/lib/matplotlib/tests/test_table.py index 4ce0577c0e76..d458d071b419 100644 --- a/lib/matplotlib/tests/test_table.py +++ b/lib/matplotlib/tests/test_table.py @@ -194,3 +194,8 @@ def test_table_cells(): cell2 = CustomCell((0, 0), 1, 2, visible_edges=None) table[2, 1] = cell2 assert table[2, 1] is cell2 + + # make sure gettitem support has not broken + # properties and setp + table.properties() + plt.setp(table)