diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 54a0908da737..2cc09a5931f6 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -425,7 +425,7 @@ def set_color(self, c): def _set_hatchcolor(self, color): color = mpl._val_or_rc(color, 'hatch.color') - if color == 'edge': + if cbook._str_equal(color, 'edge'): self._hatch_color = 'edge' else: self._hatch_color = colors.to_rgba(color, self._alpha) @@ -439,8 +439,6 @@ def set_hatchcolor(self, color): ---------- color : :mpltype:`color` or 'edge' or None """ - if cbook._str_equal(color, 'edge'): - color = 'edge' self._original_hatchcolor = color self._set_hatchcolor(color) diff --git a/lib/matplotlib/tests/test_patches.py b/lib/matplotlib/tests/test_patches.py index e76c6f6ae874..78fad6a07ec8 100644 --- a/lib/matplotlib/tests/test_patches.py +++ b/lib/matplotlib/tests/test_patches.py @@ -1023,6 +1023,9 @@ def test_patch_hatchcolor_inherit_logic(): rect.set_edgecolor('green') assert mcolors.same_color(rect.get_hatchcolor(), 'purple') + # Smoke test for setting with numpy array + rect.set_hatchcolor(np.ones(3)) + def test_patch_hatchcolor_fallback_logic(): # Test for when hatchcolor parameter is passed