@@ -2391,19 +2391,19 @@ 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 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.
24072407
24082408 Parameters
24092409 ----------
@@ -2462,25 +2462,39 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
24622462
24632463 Returns
24642464 -------
2465- a :class:`~matplotlib.container.StemContainer`
2465+ :class:`~matplotlib.container.StemContainer`
2466+ The stemcontainer may be treated like a tuple
2467+ (*markerline*, *stemlines*, *baseline*)
24662468
2467- The stemcontainer may be treated like a tuple
2468- (*markerline*, *stemlines*, *baseline*)
24692469
2470+ Notes
2471+ -----
24702472
24712473 .. seealso::
24722474 The MATLAB function
24732475 `stem <http://www.mathworks.com/help/techdoc/ref/stem.html>`_
24742476 which inspired this method.
24752477
24762478 """
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 )
24772493 if kwargs :
2478- # TODO: to remove the deprecated behavior, simply remove **kwargs
2479- # from the function signature and remove this warning.
24802494 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." % (
24842498 next (k for k in kwargs ), )
24852499 )
24862500
@@ -2503,7 +2517,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
25032517 second = np .arange (len (y ))
25042518 x = second
25052519
2506- # Popping some defaults
2520+ # defaults for formats
25072521 if linefmt is None :
25082522 try :
25092523 # fallback to positional argument
@@ -2550,9 +2564,6 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
25502564 else :
25512565 basestyle , basemarker , basecolor = _process_plot_format (basefmt )
25522566
2553- if bottom is None :
2554- bottom = 0
2555-
25562567 markerline , = self .plot (x , y , color = markercolor , linestyle = markerstyle ,
25572568 marker = markermarker , label = "_nolegend_" )
25582569
0 commit comments