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

Skip to content

Commit aef8acd

Browse files
NelleVQuLogic
authored andcommitted
Merge pull request #7522 from dstansby/table-argcheck
Check at least one argument is provided for plt.table
1 parent 7098926 commit aef8acd

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5843,10 +5843,10 @@ def table(self, **kwargs):
58435843
colLabels=None, colColours=None, colLoc='center',
58445844
loc='bottom', bbox=None):
58455845
5846-
Returns a :class:`matplotlib.table.Table` instance. For finer
5847-
grained control over tables, use the
5848-
:class:`~matplotlib.table.Table` class and add it to the axes
5849-
with :meth:`~matplotlib.axes.Axes.add_table`.
5846+
Returns a :class:`matplotlib.table.Table` instance. Either `cellText`
5847+
or `cellColours` must be provided. For finer grained control over
5848+
tables, use the :class:`~matplotlib.table.Table` class and add it to
5849+
the axes with :meth:`~matplotlib.axes.Axes.add_table`.
58505850
58515851
Thanks to John Gill for providing the class and table.
58525852

lib/matplotlib/table.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,10 @@ def table(ax,
553553
Thanks to John Gill for providing the class and table.
554554
"""
555555

556+
if cellColours is None and cellText is None:
557+
raise ValueError('At least one argument from "cellColours" or '
558+
'"cellText" must be provided to create a table.')
559+
556560
# Check we have some cellText
557561
if cellText is None:
558562
# assume just colours are needed

0 commit comments

Comments
 (0)