Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88cdf1b

Browse files
committed
Make stem formatting parameters keyword only.
This will allow to simplify the implementation because, currently, `stem(*args, linefmt=None, ...)` still tries to resolve excess positionally passed args, to *linefmt* and following parameters, which is quite a bit of logic. OTOH, since we have 3 formats, passing them positionally is already difficult from a usability/readability perspective, because they can easily be mixed up.
1 parent 1cec9c1 commit 88cdf1b

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Passing formatting parameters positionally to ``stem()`` is deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,12 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
28492849
args = ()
28502850
else:
28512851
locs, heads, *args = args
2852+
if args:
2853+
_api.warn_deprecated(
2854+
"3.5",
2855+
message="Passing the linefmt parameter positionally is "
2856+
"deprecated since Matplotlib %(since)s; the "
2857+
"parameter will become keyword-only %(removal)s.")
28522858

28532859
if orientation == 'vertical':
28542860
locs, heads = self._process_unit_info([("x", locs), ("y", heads)])

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,16 +3641,16 @@ def test_stem_args():
36413641
# Test the call signatures
36423642
ax.stem(y)
36433643
ax.stem(x, y)
3644-
ax.stem(x, y, 'r--')
3645-
ax.stem(x, y, 'r--', basefmt='b--')
3644+
ax.stem(x, y, linefmt='r--')
3645+
ax.stem(x, y, linefmt='r--', basefmt='b--')
36463646

36473647

36483648
def test_stem_dates():
36493649
fig, ax = plt.subplots(1, 1)
36503650
xs = [dateutil.parser.parse("2013-9-28 11:00:00"),
36513651
dateutil.parser.parse("2013-9-28 12:00:00")]
36523652
ys = [100, 200]
3653-
ax.stem(xs, ys, "*-")
3653+
ax.stem(xs, ys)
36543654

36553655

36563656
@pytest.mark.parametrize("use_line_collection", [True, False],

0 commit comments

Comments
 (0)