Skip to content

Commit 1682db7

Browse files
committed
explicit keywords for Axes.stem()
1 parent b150eb5 commit 1682db7

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,8 @@ def broken_barh(self, xranges, yrange, **kwargs):
23902390
return col
23912391

23922392
@_preprocess_data(replace_all_args=True, label_namer=None)
2393-
def stem(self, *args, **kwargs):
2393+
def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2394+
label=None, **kwargs):
23942395
"""
23952396
Create a stem plot.
23962397
@@ -2449,6 +2450,15 @@ def stem(self, *args, **kwargs):
24492450
The label to use for the stems in legends.
24502451
24512452
2453+
Other Parameters
2454+
----------------
2455+
**kwargs
2456+
No other parameters are supported. They are currently ignored
2457+
silently for backward compatibility. This behavior is deprecated.
2458+
Future versions will not accept any other parameters and will
2459+
raise a TypeError instead.
2460+
2461+
24522462
Returns
24532463
-------
24542464
a :class:`~matplotlib.container.StemContainer`
@@ -2483,10 +2493,9 @@ def stem(self, *args, **kwargs):
24832493
x = second
24842494

24852495
# Popping some defaults
2486-
try:
2487-
linefmt = kwargs['linefmt']
2488-
except KeyError:
2496+
if linefmt is None:
24892497
try:
2498+
# fallback to positional argument
24902499
linefmt = args[0]
24912500
except IndexError:
24922501
linecolor = 'C0'
@@ -2497,10 +2506,10 @@ def stem(self, *args, **kwargs):
24972506
_process_plot_format(linefmt)
24982507
else:
24992508
linestyle, linemarker, linecolor = _process_plot_format(linefmt)
2500-
try:
2501-
markerfmt = kwargs['markerfmt']
2502-
except KeyError:
2509+
2510+
if markerfmt is None:
25032511
try:
2512+
# fallback to positional argument
25042513
markerfmt = args[1]
25052514
except IndexError:
25062515
markercolor = 'C0'
@@ -2512,10 +2521,10 @@ def stem(self, *args, **kwargs):
25122521
else:
25132522
markerstyle, markermarker, markercolor = \
25142523
_process_plot_format(markerfmt)
2515-
try:
2516-
basefmt = kwargs['basefmt']
2517-
except KeyError:
2524+
2525+
if basefmt is None:
25182526
try:
2527+
# fallback to positional argument
25192528
basefmt = args[2]
25202529
except IndexError:
25212530
if rcParams['_internal.classic_mode']:
@@ -2530,15 +2539,12 @@ def stem(self, *args, **kwargs):
25302539
else:
25312540
basestyle, basemarker, basecolor = _process_plot_format(basefmt)
25322541

2533-
bottom = kwargs.pop('bottom', None)
2534-
label = kwargs.pop('label', None)
2542+
if bottom is None:
2543+
bottom = 0
25352544

25362545
markerline, = self.plot(x, y, color=markercolor, linestyle=markerstyle,
25372546
marker=markermarker, label="_nolegend_")
25382547

2539-
if bottom is None:
2540-
bottom = 0
2541-
25422548
stemlines = []
25432549
for thisx, thisy in zip(x, y):
25442550
l, = self.plot([thisx, thisx], [bottom, thisy],

0 commit comments

Comments
 (0)