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

Skip to content

FIX: properties and setp on Table instances #10805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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))
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)