Skip to content

Commit c3567c3

Browse files
larsonergreglucas
andauthored
BUG: Fix regression with set_hatchcolor (#29427)
* BUG: Fix regression with set_hatchcolor * Update lib/matplotlib/patches.py Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com> * FIX: Remove --------- Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com>
1 parent 75c5362 commit c3567c3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/matplotlib/patches.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def set_color(self, c):
425425

426426
def _set_hatchcolor(self, color):
427427
color = mpl._val_or_rc(color, 'hatch.color')
428-
if color == 'edge':
428+
if cbook._str_equal(color, 'edge'):
429429
self._hatch_color = 'edge'
430430
else:
431431
self._hatch_color = colors.to_rgba(color, self._alpha)
@@ -439,8 +439,6 @@ def set_hatchcolor(self, color):
439439
----------
440440
color : :mpltype:`color` or 'edge' or None
441441
"""
442-
if cbook._str_equal(color, 'edge'):
443-
color = 'edge'
444442
self._original_hatchcolor = color
445443
self._set_hatchcolor(color)
446444

lib/matplotlib/tests/test_patches.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,9 @@ def test_patch_hatchcolor_inherit_logic():
10231023
rect.set_edgecolor('green')
10241024
assert mcolors.same_color(rect.get_hatchcolor(), 'purple')
10251025

1026+
# Smoke test for setting with numpy array
1027+
rect.set_hatchcolor(np.ones(3))
1028+
10261029

10271030
def test_patch_hatchcolor_fallback_logic():
10281031
# Test for when hatchcolor parameter is passed

0 commit comments

Comments
 (0)