Skip to content

Backport PR #21126 on branch v3.5.x (Deprecate passing formatting parameters positionally to stem()) #21169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/api/next_api_changes/deprecations/21126-TH.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Passing formatting parameters positionally to ``stem()`` is deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 changes: 6 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3642,16 +3642,16 @@ 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():
fig, ax = plt.subplots(1, 1)
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],
Expand Down