Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6eb84ef

Browse files
committed
MNT: lock in hatch rcParam at artist creation time
also remove some dead-code
1 parent d70795d commit 6eb84ef

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,8 +1111,6 @@ def get_hatch_color(self):
11111111
"""
11121112
Gets the color to use for hatching.
11131113
"""
1114-
if self._hatch_color is None:
1115-
return colors.to_rgba(rcParams['hatch.color'])
11161114
return self._hatch_color
11171115

11181116
def set_hatch_color(self, hatch_color):

lib/matplotlib/collections.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __init__(self,
136136
self._linewidths = [0]
137137
self._is_filled = True # May be modified by set_facecolor().
138138

139-
self._hatch_color = None
139+
self._hatch_color = mcolors.to_rgba(mpl.rcParams['hatch.color'])
140140
self.set_facecolor(facecolors)
141141
self.set_edgecolor(edgecolors)
142142
self.set_linewidth(linewidths)
@@ -294,14 +294,12 @@ def draw(self, renderer):
294294

295295
if self._hatch:
296296
gc.set_hatch(self._hatch)
297-
if self._hatch_color is not None:
298-
try:
299-
gc.set_hatch_color(self._hatch_color)
300-
except AttributeError:
301-
# if we end up with a GC that does not have this method
302-
warnings.warn("Your backend does not support setting the "
303-
"hatch color.")
304-
297+
try:
298+
gc.set_hatch_color(self._hatch_color)
299+
except AttributeError:
300+
# if we end up with a GC that does not have this method
301+
warnings.warn("Your backend does not support setting the "
302+
"hatch color.")
305303

306304
if self.get_sketch_params() is not None:
307305
gc.set_sketch_params(*self.get_sketch_params())

lib/matplotlib/patches.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(self,
114114
if antialiased is None:
115115
antialiased = mpl.rcParams['patch.antialiased']
116116

117-
self._hatch_color = None
117+
self._hatch_color = colors.to_rgba(mpl.rcParams['hatch.color'])
118118
self._fill = True # needed for set_facecolor call
119119
if color is not None:
120120
if (edgecolor is not None or facecolor is not None):
@@ -551,13 +551,12 @@ def draw(self, renderer):
551551

552552
if self._hatch:
553553
gc.set_hatch(self._hatch)
554-
if self._hatch_color is not None:
555-
try:
556-
gc.set_hatch_color(self._hatch_color)
557-
except AttributeError:
558-
# if we end up with a GC that does not have this method
559-
warnings.warn("Your backend does not have support for "
560-
"setting the hatch color.")
554+
try:
555+
gc.set_hatch_color(self._hatch_color)
556+
except AttributeError:
557+
# if we end up with a GC that does not have this method
558+
warnings.warn("Your backend does not have support for "
559+
"setting the hatch color.")
561560

562561
if self.get_sketch_params() is not None:
563562
gc.set_sketch_params(*self.get_sketch_params())

0 commit comments

Comments
 (0)