@@ -5029,20 +5029,22 @@ def broken_barh(self, xranges, yrange, **kwargs):
50295029
50305030 return col
50315031
5032- def stem (self , x , y , linefmt = 'b-' , markerfmt = 'bo' , basefmt = 'r-' ,
5033- bottom = None , label = None ):
5032+ def stem (self , * args , ** kwargs ):
50345033 """
50355034 Create a stem plot.
50365035
5037- Call signature ::
5036+ Call signatures ::
50385037
5038+ stem(y, linefmt='b-', markerfmt='bo', basefmt='r-')
50395039 stem(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
50405040
50415041 A stem plot plots vertical lines (using *linefmt*) at each *x*
50425042 location from the baseline to *y*, and places a marker there
50435043 using *markerfmt*. A horizontal line at 0 is is plotted using
50445044 *basefmt*.
50455045
5046+ If no *x* values are provided, the default is (0, 1, ..., len(y) - 1)
5047+
50465048 Return value is a tuple (*markerline*, *stemlines*,
50475049 *baseline*).
50485050
@@ -5061,6 +5063,37 @@ def stem(self, x, y, linefmt='b-', markerfmt='bo', basefmt='r-',
50615063 self .cla ()
50625064 self .hold (True )
50635065
5066+ # Assume there's at least one data array
5067+ y = np .asarray (args [0 ], dtype = np .float )
5068+ args = args [1 :]
5069+
5070+ # Try a second one
5071+ try :
5072+ second = np .asarray (args [0 ], dtype = np .float )
5073+ x , y = y , second
5074+ args = args [1 :]
5075+ except (IndexError , ValueError ):
5076+ # The second array doesn't make sense, or it doesn't exist
5077+ second = np .arange (len (y ))
5078+ x = second
5079+
5080+ # Popping some defaults
5081+ try :
5082+ linefmt = kwargs .pop ('linefmt' , args [0 ])
5083+ except IndexError :
5084+ linefmt = kwargs .pop ('linefmt' , 'b-' )
5085+ try :
5086+ markerfmt = kwargs .pop ('markerfmt' , args [1 ])
5087+ except IndexError :
5088+ markerfmt = kwargs .pop ('markerfmt' , 'bo' )
5089+ try :
5090+ basefmt = kwargs .pop ('basefmt' , args [2 ])
5091+ except IndexError :
5092+ basefmt = kwargs .pop ('basefmt' , 'r-' )
5093+
5094+ bottom = kwargs .pop ('bottom' , None )
5095+ label = kwargs .pop ('label' , None )
5096+
50645097 markerline , = self .plot (x , y , markerfmt , label = "_nolegend_" )
50655098
50665099 if bottom is None :
0 commit comments