Skip to content

Commit c7c1136

Browse files
authored
Merge pull request #30268 from meeseeksmachine/auto-backport-of-pr-30233-on-v3.10.x
Backport PR #30233 on branch v3.10.x (Check that stem input is 1D)
2 parents e0739f3 + dd24d49 commit c7c1136

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)