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

Skip to content

Calling properties() on Table raises exception #10732

Closed
@atticusfyj

Description

@atticusfyj

Bug report

Bug summary

When calling .properties() on Table, exception is raised with the message ''Only tuples length 2 are accepted as coordinates".

Code for reproduction

import matplotlib.pyplot as plt


plt.table(cellText=['0']).properties()

Actual outcome

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/.local/lib/python3.5/site-packages/matplotlib/table.py in __getitem__(self, position)
    319         try:
--> 320             row, col = position[0], position[1]
    321         except Exception:

TypeError: 'int' object is not subscriptable

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-4-de5c16c3d6d6> in <module>()
      2 
      3 
----> 4 plt.table(cellText=['0']).properties()

~/.local/lib/python3.5/site-packages/matplotlib/artist.py in properties(self)
    982         return a dictionary mapping property name -> value for all Artist props
    983         """
--> 984         return ArtistInspector(self).properties()
    985 
    986     def set(self, **kwargs):

~/.local/lib/python3.5/site-packages/matplotlib/artist.py in __init__(self, o)
   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]

~/.local/lib/python3.5/site-packages/matplotlib/table.py in __getitem__(self, position)
    320             row, col = position[0], position[1]
    321         except Exception:
--> 322             raise KeyError('Only tuples length 2 are accepted as coordinates')
    323         return self._cells[row, col]
    324 

KeyError: 'Only tuples length 2 are accepted as coordinates'

Expected outcome

Used to work in v2.1.2.

Matplotlib version

  • Operating system: CentOS
  • Matplotlib version: 2.2.0
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.5.4
  • Jupyter version (if applicable): 5.1.0
  • Other libraries: N/A

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions