From 03fd172a1ae67b77277bdd0e257d1da9026ea4d4 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 11 Oct 2017 10:15:29 +0100 Subject: [PATCH] Backport PR #9353: Fix edgecolor being only applied to first bar. --- lib/matplotlib/axes/_axes.py | 7 ++++--- lib/matplotlib/tests/test_axes.py | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 0b97242c91a5..7281555f9f0e 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2108,9 +2108,10 @@ def bar(self, *args, **kwargs): if edgecolor is None: edgecolor = itertools.repeat(None) else: - edgecolor = itertools.chain(mcolors.to_rgba_array(edgecolor), - # Fallback if edgecolor == "none". - itertools.repeat([0, 0, 0, 0])) + edgecolor = itertools.chain( + itertools.cycle(mcolors.to_rgba_array(edgecolor)), + # Fallback if edgecolor == "none". + itertools.repeat([0, 0, 0, 0])) # lets do some conversions now since some types cannot be # subtracted uniformly diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 0c22740a4f09..310baf41606c 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -5260,12 +5260,15 @@ def test_eventplot_legend(): plt.legend() -def test_bar_single_height(): +def test_bar_broadcast_args(): fig, ax = plt.subplots() - # Check that a bar chart with a single height for all bars works + # Check that a bar chart with a single height for all bars works. ax.bar(range(4), 1) - # Check that a horizontal chart with one width works + # Check that a horizontal chart with one width works. ax.bar(0, 1, bottom=range(4), width=1, orientation='horizontal') + # Check that edgecolor gets broadcasted. + rect1, rect2 = ax.bar([0, 1], [0, 1], edgecolor=(.1, .2, .3, .4)) + assert rect1.get_edgecolor() == rect2.get_edgecolor() == (.1, .2, .3, .4) def test_invalid_axis_limits():