Skip to content

Commit dd24d49

Browse files
dstansbymeeseeksmachine
authored andcommitted
Backport PR #30233: Check that stem input is 1D
1 parent e0739f3 commit dd24d49

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3171,6 +3171,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
31713171
else: # horizontal
31723172
heads, locs = self._process_unit_info([("x", heads), ("y", locs)])
31733173

3174+
heads = cbook._check_1d(heads)
3175+
locs = cbook._check_1d(locs)
3176+
31743177
# resolve line format
31753178
if linefmt is None:
31763179
linefmt = args[0] if len(args) > 0 else "C0-"

lib/matplotlib/tests/test_axes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,6 +4538,11 @@ def _assert_equal(stem_container, expected):
45384538
_assert_equal(ax.stem(y, linefmt='r--'), expected=([0, 1, 2], y))
45394539
_assert_equal(ax.stem(y, 'r--'), expected=([0, 1, 2], y))
45404540

4541+
with pytest.raises(ValueError):
4542+
ax.stem([[y]])
4543+
with pytest.raises(ValueError):
4544+
ax.stem([[x]], y)
4545+
45414546

45424547
def test_stem_markerfmt():
45434548
"""Test that stem(..., markerfmt=...) produces the intended markers."""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy