Skip to content

Commit 5d44728

Browse files
committed
revert explicit keyword arguments in Axes.stem
1 parent c6407b1 commit 5d44728

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,19 +2391,22 @@ def broken_barh(self, xranges, yrange, **kwargs):
23912391
return col
23922392

23932393
@_preprocess_data(replace_all_args=True, label_namer=None)
2394-
def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2395-
label=None, **kwargs):
2394+
def stem(self, *args, **kwargs):
23962395
"""
23972396
Create a stem plot.
23982397
2399-
Call signatures::
2400-
2401-
stem(y)
2402-
stem(x, y)
2403-
24042398
A stem plot plots vertical lines at each *x* location from the baseline
24052399
to *y*, and places a marker there.
24062400
2401+
Call signatures::
2402+
2403+
stem([x,] y, **kwargs)
2404+
stem([x,] y, linefmt, **kwargs)
2405+
stem([x,] y, linefmt, markerfmt, **kwargs)
2406+
stem([x,] y, linefmt, markerfmt, basefmt, **kwargs)
2407+
2408+
The x-positions are optional. The formats may be provided either as
2409+
positional or as keyword-arguments.
24072410
24082411
Parameters
24092412
----------
@@ -2474,9 +2477,21 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
24742477
which inspired this method.
24752478
24762479
"""
2480+
2481+
# kwargs handling
2482+
# We would like to have a signature with explicit kewords:
2483+
# stem(*args, linefmt=None, markerfmt=None, basefmt=None,
2484+
# bottom=0, label=None)
2485+
# Unfortunately, this is not supported in Python 2.x. There, *args
2486+
# can only exist after keyword arguments.
2487+
linefmt = kwargs.pop('linefmt', None)
2488+
markerfmt = kwargs.pop('markerfmt', None)
2489+
basefmt = kwargs.pop('basefmt', None)
2490+
bottom = kwargs.pop('bottom', None)
2491+
if bottom is None:
2492+
bottom = 0
2493+
label = kwargs.pop('label', None)
24772494
if kwargs:
2478-
# TODO: to remove the deprecated behavior, simply remove **kwargs
2479-
# from the function signature and remove this warning.
24802495
warn_deprecated(since='2.2',
24812496
message = "stem() got an unexpected keyword "
24822497
"argument '%s'. This will raise a "
@@ -2503,7 +2518,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
25032518
second = np.arange(len(y))
25042519
x = second
25052520

2506-
# Popping some defaults
2521+
# defaults for formats
25072522
if linefmt is None:
25082523
try:
25092524
# fallback to positional argument
@@ -2550,8 +2565,6 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
25502565
else:
25512566
basestyle, basemarker, basecolor = _process_plot_format(basefmt)
25522567

2553-
if bottom is None:
2554-
bottom = 0
25552568

25562569
markerline, = self.plot(x, y, color=markercolor, linestyle=markerstyle,
25572570
marker=markermarker, label="_nolegend_")

0 commit comments

Comments
 (0)