Skip to content

Commit 55d1a5e

Browse files
rcomertimhoffm
andcommitted
Apply suggestions from timhoffm code review
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent 2b5ee9a commit 55d1a5e

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,9 +3194,15 @@ def grouped_bar(self, heights, *, positions=None, group_spacing=1.5, bar_spacing
31943194
31953195
**kwargs : `.Rectangle` properties
31963196
3197-
The following properties additionally accept a sequence of values
3198-
corresponding to the datasets in *heights*:
3199-
*edgecolor*, *facecolor*, *linewidth*, *linestyle*, *hatch*.
3197+
Properties applied to all bars. The following properties additionally
3198+
accept a sequence of values corresponding to the datasets in
3199+
*heights*:
3200+
3201+
- *edgecolor*
3202+
- *facecolor*
3203+
- *linewidth*
3204+
- *linestyle*
3205+
- *hatch*
32003206
32013207
%(Rectangle:kwdoc)s
32023208

lib/matplotlib/tests/test__style_helpers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
('linestyle', ["-", "--", ":"]),
1212
('linewidth', [1, 1.5, 2])])
1313
def test_style_generator_list(key, value):
14+
"""Test that style parameter lists are distributed to the generator."""
1415
kw = {'foo': 12, key: value}
1516
new_kw, gen = style_generator(kw)
1617

@@ -33,6 +34,7 @@ def test_style_generator_list(key, value):
3334
('linestyle', "-"),
3435
('linewidth', 1)])
3536
def test_style_generator_single(key, value):
37+
"""Test that single-value style parameters are distributed to the generator."""
3638
kw = {'foo': 12, key: value}
3739
new_kw, gen = style_generator(kw)
3840

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

4951

5052
@pytest.mark.parametrize('key', ['facecolor', 'hatch', 'linestyle'])
51-
def test_style_generator_empty(key):
53+
def test_style_generator_raises_on_empty_style_parameter_list(key):
5254
kw = {key: []}
5355
with pytest.raises(TypeError, match=f'{key} must not be an empty sequence'):
5456
style_generator(kw)
5557

5658

5759
def test_style_generator_sequence_type_styles():
60+
"""
61+
Test that sequence type style values are detected as single value
62+
and passed to a all elements of the generator.
63+
"""
5864
kw = {'facecolor': ('r', 0.5),
5965
'edgecolor': [0.5, 0.5, 0.5],
6066
'linestyle': (0, (1, 1))}

lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,18 +3450,18 @@ def test_stackplot_facecolor():
34503450
y1 = 1.0 * x
34513451
y2 = 2.0 * x + 1
34523452

3453-
fcols = ['r', 'b']
3453+
facecolors = ['r', 'b']
34543454

34553455
fig, ax = plt.subplots()
34563456

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

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

34663466

34673467
def test_stackplot_subfig_legend():

0 commit comments

Comments
 (0)