diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 086f19af7750..194b2cdef628 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -5873,10 +5873,10 @@ def table(self, **kwargs): colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None): - Returns a :class:`matplotlib.table.Table` instance. For finer - grained control over tables, use the - :class:`~matplotlib.table.Table` class and add it to the axes - with :meth:`~matplotlib.axes.Axes.add_table`. + Returns a :class:`matplotlib.table.Table` instance. Either `cellText` + or `cellColours` must be provided. For finer grained control over + tables, use the :class:`~matplotlib.table.Table` class and add it to + the axes with :meth:`~matplotlib.axes.Axes.add_table`. Thanks to John Gill for providing the class and table. diff --git a/lib/matplotlib/table.py b/lib/matplotlib/table.py index c765ec1fb072..14407ed21695 100644 --- a/lib/matplotlib/table.py +++ b/lib/matplotlib/table.py @@ -581,6 +581,10 @@ def table(ax, Thanks to John Gill for providing the class and table. """ + if cellColours is None and cellText is None: + raise ValueError('At least one argument from "cellColours" or ' + '"cellText" must be provided to create a table.') + # Check we have some cellText if cellText is None: # assume just colours are needed