Skip to content
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
7 changes: 3 additions & 4 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def legend(self, *args, **kwargs):
*args,
**kwargs)
if len(extra_args):
raise TypeError('legend only accepts two non-keyword arguments')
_api.nargs_error('legend', '0-2', len(args))
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
self.legend_._remove_method = self._remove_legend
return self.legend_
Expand Down Expand Up @@ -2970,8 +2970,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
which inspired this method.
"""
if not 1 <= len(args) <= 3:
raise TypeError('stem expected between 1 or 3 positional '
f'arguments, got {args}')
_api.nargs_error('stem', '1-3', len(args))
_api.check_in_list(['horizontal', 'vertical'], orientation=orientation)

if len(args) == 1:
Expand Down Expand Up @@ -6383,7 +6382,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
else:
raise TypeError("arguments do not match valid signatures")
else:
raise TypeError("need 1 argument or 3 arguments")
_api.nargs_error('pcolorfast', '1 or 3', len(args))

if style == "quadmesh":
# data point in each cell is value at lower left corner
Expand Down
5 changes: 1 addition & 4 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,11 +1352,8 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):

# Two arguments:
# * user defined handles and labels
elif len(args) >= 2:
else:
handles, labels = args[:2]
extra_args = args[2:]

else:
raise TypeError('Invalid arguments to legend.')

return handles, labels, extra_args, kwargs
2 changes: 1 addition & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def cycler(*args, **kwargs):
elif len(args) == 2:
pairs = [(args[0], args[1])]
elif len(args) > 2:
raise TypeError("No more than 2 positional arguments allowed")
_api.nargs_error('cycler', '0-2', len(args))
else:
pairs = kwargs.items()

Expand Down