Skip to content

Commit c192e37

Browse files
authored
Merge pull request #8575 from QuLogic/legend-hatching
Legend hatching fixes
2 parents b0ca78c + ae5bb59 commit c192e37

File tree

6 files changed

+1062
-2
lines changed

6 files changed

+1062
-2
lines changed

lib/matplotlib/legend_handler.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ class HandlerPolyCollection(HandlerBase):
592592
"""
593593
def _update_prop(self, legend_handle, orig_handle):
594594
def first_color(colors):
595+
if colors is None:
596+
return None
595597
colors = mcolors.to_rgba_array(colors)
596598
if len(colors):
597599
return colors[0]
@@ -602,8 +604,12 @@ def get_first(prop_array):
602604
return prop_array[0]
603605
else:
604606
return None
605-
legend_handle.set_edgecolor(first_color(orig_handle.get_edgecolor()))
606-
legend_handle.set_facecolor(first_color(orig_handle.get_facecolor()))
607+
edgecolor = getattr(orig_handle, '_original_edgecolor',
608+
orig_handle.get_edgecolor())
609+
legend_handle.set_edgecolor(first_color(edgecolor))
610+
facecolor = getattr(orig_handle, '_original_facecolor',
611+
orig_handle.get_facecolor())
612+
legend_handle.set_facecolor(first_color(facecolor))
607613
legend_handle.set_fill(orig_handle.get_fill())
608614
legend_handle.set_hatch(orig_handle.get_hatch())
609615
legend_handle.set_linewidth(get_first(orig_handle.get_linewidths()))

lib/matplotlib/patches.py

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def update_from(self, other):
200200
self._facecolor = other._facecolor
201201
self._fill = other._fill
202202
self._hatch = other._hatch
203+
self._hatch_color = other._hatch_color
203204
# copy the unscaled dash pattern
204205
self._us_dashes = other._us_dashes
205206
self.set_linewidth(other._linewidth) # also sets dash properties
Binary file not shown.

0 commit comments

Comments
 (0)