Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply suggestions from timhoffm code review
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
  • Loading branch information
rcomer and timhoffm committed Dec 7, 2025
commit 55d1a5e9d66d791e8b19e335f4c3563044d66a76
12 changes: 9 additions & 3 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3194,9 +3194,15 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing

**kwargs : `.Rectangle` properties

The following properties additionally accept a sequence of values
corresponding to the datasets in *heights*:
*edgecolor*, *facecolor*, *linewidth*, *linestyle*, *hatch*.
Properties applied to all bars. The following properties additionally
accept a sequence of values corresponding to the datasets in
*heights*:

- *edgecolor*
- *facecolor*
- *linewidth*
- *linestyle*
- *hatch*

%(Rectangle:kwdoc)s

Expand Down
8 changes: 7 additions & 1 deletion lib/matplotlib/tests/test__style_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
('linestyle', ["-", "--", ":"]),
('linewidth', [1, 1.5, 2])])
def test_style_generator_list(key, value):
Comment thread
rcomer marked this conversation as resolved.
"""Test that style parameter lists are distributed to the generator."""
kw = {'foo': 12, key: value}
new_kw, gen = style_generator(kw)

Expand All @@ -33,6 +34,7 @@ def test_style_generator_list(key, value):
('linestyle', "-"),
('linewidth', 1)])
def test_style_generator_single(key, value):
Comment thread
rcomer marked this conversation as resolved.
"""Test that single-value style parameters are distributed to the generator."""
kw = {'foo': 12, key: value}
new_kw, gen = style_generator(kw)

Expand All @@ -48,13 +50,17 @@ def test_style_generator_single(key, value):


@pytest.mark.parametrize('key', ['facecolor', 'hatch', 'linestyle'])
def test_style_generator_empty(key):
def test_style_generator_raises_on_empty_style_parameter_list(key):
kw = {key: []}
with pytest.raises(TypeError, match=f'{key} must not be an empty sequence'):
style_generator(kw)


def test_style_generator_sequence_type_styles():
"""
Test that sequence type style values are detected as single value
and passed to a all elements of the generator.
"""
kw = {'facecolor': ('r', 0.5),
Comment thread
rcomer marked this conversation as resolved.
'edgecolor': [0.5, 0.5, 0.5],
'linestyle': (0, (1, 1))}
Expand Down
14 changes: 7 additions & 7 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3450,18 +3450,18 @@ def test_stackplot_facecolor():
y1 = 1.0 * x
y2 = 2.0 * x + 1

fcols = ['r', 'b']
facecolors = ['r', 'b']

fig, ax = plt.subplots()

colls = ax.stackplot(x, y1, y2, facecolor=fcols, colors=['c', 'm'])
for coll, fcol in zip(colls, fcols):
assert mcolors.same_color(coll.get_facecolor(), fcol)
colls = ax.stackplot(x, y1, y2, facecolor=facecolors, colors=['c', 'm'])
for coll, fcol in zip(colls, facecolors):
assert mcolors.same_color(coll.get_facecolor(), facecolors)

# Plural alias should also work
colls = ax.stackplot(x, y1, y2, facecolors=fcols, colors=['c', 'm'])
for coll, fcol in zip(colls, fcols):
assert mcolors.same_color(coll.get_facecolor(), fcol)
colls = ax.stackplot(x, y1, y2, facecolors=facecolors, colors=['c', 'm'])
for coll, fcol in zip(colls, facecolors):
assert mcolors.same_color(coll.get_facecolor(), facecolors)


def test_stackplot_subfig_legend():
Expand Down