@@ -2391,19 +2391,19 @@ 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 signature::
2402
+
2403
+ stem([x,] y, linefmt=None, markerfmt=None, basefmt=None)
2404
+
2405
+ The x-positions are optional. The formats may be provided either as
2406
+ positional or as keyword-arguments.
2407
2407
2408
2408
Parameters
2409
2409
----------
@@ -2462,25 +2462,39 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2462
2462
2463
2463
Returns
2464
2464
-------
2465
- a :class:`~matplotlib.container.StemContainer`
2465
+ :class:`~matplotlib.container.StemContainer`
2466
+ The stemcontainer may be treated like a tuple
2467
+ (*markerline*, *stemlines*, *baseline*)
2466
2468
2467
- The stemcontainer may be treated like a tuple
2468
- (*markerline*, *stemlines*, *baseline*)
2469
2469
2470
+ Notes
2471
+ -----
2470
2472
2471
2473
.. seealso::
2472
2474
The MATLAB function
2473
2475
`stem <http://www.mathworks.com/help/techdoc/ref/stem.html>`_
2474
2476
which inspired this method.
2475
2477
2476
2478
"""
2479
+
2480
+ # kwargs handling
2481
+ # We would like to have a signature with explicit kewords:
2482
+ # stem(*args, linefmt=None, markerfmt=None, basefmt=None,
2483
+ # bottom=0, label=None)
2484
+ # Unfortunately, this is not supported in Python 2.x. There, *args
2485
+ # can only exist after keyword arguments.
2486
+ linefmt = kwargs .pop ('linefmt' , None )
2487
+ markerfmt = kwargs .pop ('markerfmt' , None )
2488
+ basefmt = kwargs .pop ('basefmt' , None )
2489
+ bottom = kwargs .pop ('bottom' , None )
2490
+ if bottom is None :
2491
+ bottom = 0
2492
+ label = kwargs .pop ('label' , None )
2477
2493
if kwargs :
2478
- # TODO: to remove the deprecated behavior, simply remove **kwargs
2479
- # from the function signature and remove this warning.
2480
2494
warn_deprecated (since = '2.2' ,
2481
- message = "stem() got an unexpected keyword "
2482
- "argument '%s'. This will raise a "
2483
- "TypeError in future versions." % (
2495
+ message = "stem() got an unexpected keyword "
2496
+ "argument '%s'. This will raise a "
2497
+ "TypeError in future versions." % (
2484
2498
next (k for k in kwargs ), )
2485
2499
)
2486
2500
@@ -2503,7 +2517,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2503
2517
second = np .arange (len (y ))
2504
2518
x = second
2505
2519
2506
- # Popping some defaults
2520
+ # defaults for formats
2507
2521
if linefmt is None :
2508
2522
try :
2509
2523
# fallback to positional argument
@@ -2550,9 +2564,6 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2550
2564
else :
2551
2565
basestyle , basemarker , basecolor = _process_plot_format (basefmt )
2552
2566
2553
- if bottom is None :
2554
- bottom = 0
2555
-
2556
2567
markerline , = self .plot (x , y , color = markercolor , linestyle = markerstyle ,
2557
2568
marker = markermarker , label = "_nolegend_" )
2558
2569
0 commit comments