FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #23232 on branch v3.5.x (Fix passing stem markerfmt positionally when locs are not given) by meeseeksmachine · Pull Request #23292 · matplotlib/matplotlib · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/deprecations/23232-TH.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Passing *linefmt* positionally is undeprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Positional use of all formatting parameters in `~.Axes.stem` has been
deprecated since Matplotlib 3.5. This deprecation is relaxed so that one can
still pass *linefmt* positionally, i.e. ``stem(x, y, 'r')``.
7 changes: 5 additions & 2 deletions lib/matplotlib/axes/_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2853,12 +2853,15 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
heads, = args
locs = np.arange(len(heads))
args = ()
elif isinstance(args[1], str):
heads, *args = args
locs = np.arange(len(heads))
else:
locs, heads, *args = args
if args:
if len(args) > 1:
_api.warn_deprecated(
"3.5",
message="Passing the linefmt parameter positionally is "
message="Passing the markerfmt parameter positionally is "
"deprecated since Matplotlib %(since)s; the "
"parameter will become keyword-only %(removal)s.")

Expand Down
20 changes: 14 additions & 6 deletions lib/matplotlib/tests/test_axes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3703,16 +3703,24 @@ def test_stem(use_line_collection):


def test_stem_args():
def _assert_equal(stem_container, expected):
x, y = map(list, stem_container.markerline.get_data())
assert x == expected[0]
assert y == expected[1]

fig, ax = plt.subplots()

x = list(range(10))
y = list(range(10))
x = [1, 3, 5]
y = [9, 8, 7]

# Test the call signatures
ax.stem(y)
ax.stem(x, y)
ax.stem(x, y, linefmt='r--')
ax.stem(x, y, linefmt='r--', basefmt='b--')
_assert_equal(ax.stem(y), expected=([0, 1, 2], y))
_assert_equal(ax.stem(x, y), expected=(x, y))
_assert_equal(ax.stem(x, y, linefmt='r--'), expected=(x, y))
_assert_equal(ax.stem(x, y, 'r--'), expected=(x, y))
_assert_equal(ax.stem(x, y, linefmt='r--', basefmt='b--'), expected=(x, y))
_assert_equal(ax.stem(y, linefmt='r--'), expected=([0, 1, 2], y))
_assert_equal(ax.stem(y, 'r--'), expected=([0, 1, 2], y))


def test_stem_dates():
Expand Down

Back | FazBrowse Home | New Git URL