@@ -2391,19 +2391,22 @@ def broken_barh(self, xranges, yrange, **kwargs):
2391
2391
return col
2392
2392
2393
2393
@_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 ):
2396
2395
"""
2397
2396
Create a stem plot.
2398
2397
2399
- Call signatures::
2400
-
2401
- stem(y)
2402
- stem(x, y)
2403
-
2404
2398
A stem plot plots vertical lines at each *x* location from the baseline
2405
2399
to *y*, and places a marker there.
2406
2400
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.
2407
2410
2408
2411
Parameters
2409
2412
----------
@@ -2474,9 +2477,21 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2474
2477
which inspired this method.
2475
2478
2476
2479
"""
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 )
2477
2494
if kwargs :
2478
- # TODO: to remove the deprecated behavior, simply remove **kwargs
2479
- # from the function signature and remove this warning.
2480
2495
warn_deprecated (since = '2.2' ,
2481
2496
message = "stem() got an unexpected keyword "
2482
2497
"argument '%s'. This will raise a "
@@ -2503,7 +2518,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2503
2518
second = np .arange (len (y ))
2504
2519
x = second
2505
2520
2506
- # Popping some defaults
2521
+ # defaults for formats
2507
2522
if linefmt is None :
2508
2523
try :
2509
2524
# fallback to positional argument
@@ -2550,8 +2565,6 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2550
2565
else :
2551
2566
basestyle , basemarker , basecolor = _process_plot_format (basefmt )
2552
2567
2553
- if bottom is None :
2554
- bottom = 0
2555
2568
2556
2569
markerline , = self .plot (x , y , color = markercolor , linestyle = markerstyle ,
2557
2570
marker = markermarker , label = "_nolegend_" )
0 commit comments