Skip to content

Commit e0fcf3f

Browse files
authored
Merge pull request #7522 from dstansby/table-argcheck
Check at least one argument is provided for plt.table
2 parents 57c845b + 1e54084 commit e0fcf3f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5873,10 +5873,10 @@ def table(self, **kwargs):
58735873
colLabels=None, colColours=None, colLoc='center',
58745874
loc='bottom', bbox=None):
58755875
5876-
Returns a :class:`matplotlib.table.Table` instance. For finer
5877-
grained control over tables, use the
5878-
:class:`~matplotlib.table.Table` class and add it to the axes
5879-
with :meth:`~matplotlib.axes.Axes.add_table`.
5876+
Returns a :class:`matplotlib.table.Table` instance. Either `cellText`
5877+
or `cellColours` must be provided. For finer grained control over
5878+
tables, use the :class:`~matplotlib.table.Table` class and add it to
5879+
the axes with :meth:`~matplotlib.axes.Axes.add_table`.
58805880
58815881
Thanks to John Gill for providing the class and table.
58825882

lib/matplotlib/table.py

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

584+
if cellColours is None and cellText is None:
585+
raise ValueError('At least one argument from "cellColours" or '
586+
'"cellText" must be provided to create a table.')
587+
584588
# Check we have some cellText
585589
if cellText is None:
586590
# assume just colours are needed

0 commit comments

Comments
 (0)