From 85496e77701a65921a2817f7f3aa2bafde313535 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 24 Sep 2021 19:11:48 -0400 Subject: [PATCH] Backport PR #21126: Deprecate passing formatting parameters positionally to stem() --- doc/api/next_api_changes/deprecations/21126-TH.rst | 2 ++ lib/matplotlib/axes/_axes.py | 6 ++++++ lib/matplotlib/tests/test_axes.py | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/21126-TH.rst diff --git a/doc/api/next_api_changes/deprecations/21126-TH.rst b/doc/api/next_api_changes/deprecations/21126-TH.rst new file mode 100644 index 000000000000..43df16287319 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/21126-TH.rst @@ -0,0 +1,2 @@ +Passing formatting parameters positionally to ``stem()`` is deprecated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 6855299689fc..54b3572ca48f 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2849,6 +2849,12 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, args = () else: locs, heads, *args = args + if args: + _api.warn_deprecated( + "3.5", + message="Passing the linefmt parameter positionally is " + "deprecated since Matplotlib %(since)s; the " + "parameter will become keyword-only %(removal)s.") if orientation == 'vertical': locs, heads = self._process_unit_info([("x", locs), ("y", heads)]) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index b4dbd9fdb4e1..52e5e9d94142 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -3642,8 +3642,8 @@ def test_stem_args(): # Test the call signatures ax.stem(y) ax.stem(x, y) - ax.stem(x, y, 'r--') - ax.stem(x, y, 'r--', basefmt='b--') + ax.stem(x, y, linefmt='r--') + ax.stem(x, y, linefmt='r--', basefmt='b--') def test_stem_dates(): @@ -3651,7 +3651,7 @@ def test_stem_dates(): xs = [dateutil.parser.parse("2013-9-28 11:00:00"), dateutil.parser.parse("2013-9-28 12:00:00")] ys = [100, 200] - ax.stem(xs, ys, "*-") + ax.stem(xs, ys) @pytest.mark.parametrize("use_line_collection", [True, False],