Skip to content
Closed
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 lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3309,6 +3309,8 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing
else:
group_distance = 1

if not isinstance(orientation, str):
raise ValueError(f"{orientation!r} is not a valid value for orientation")
_api.check_in_list(["vertical", "horizontal"], orientation=orientation)

if colors is None:
Expand Down
13 changes: 13 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,19 @@ def test_grouped_bar_return_value():
assert bc not in ax.containers


def test_grouped_bar_orientation_invalid():
"""Passing an invalid orientation should raise an error."""
fig, ax = plt.subplots()
x = np.arange(3)
heights = [np.array([1, 2, 3]), np.array([2, 1, 2])]

invalid_orientations = ["invalid", 1, None, np.array([1, 2, 3])]

for inval in invalid_orientations:
with pytest.raises(ValueError, match="is not a valid value for orientation"):
ax.grouped_bar(heights, positions=x, orientation=inval)


def test_boxplot_dates_pandas(pd):
# smoke test for boxplot and dates in pandas
data = np.random.rand(5, 2)
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.