|
5 | 5 |
|
6 | 6 | import six |
7 | 7 | from six.moves import map, zip |
| 8 | +import warnings |
8 | 9 |
|
9 | 10 | import math |
10 | 11 |
|
@@ -113,10 +114,10 @@ def __init__(self, |
113 | 114 | if antialiased is None: |
114 | 115 | antialiased = mpl.rcParams['patch.antialiased'] |
115 | 116 |
|
| 117 | + self._hatch_color = colors.to_rgba(mpl.rcParams['hatch.color']) |
116 | 118 | self._fill = True # needed for set_facecolor call |
117 | 119 | if color is not None: |
118 | 120 | if (edgecolor is not None or facecolor is not None): |
119 | | - import warnings |
120 | 121 | warnings.warn("Setting the 'color' property will override" |
121 | 122 | "the edgecolor or facecolor properties. ") |
122 | 123 | self.set_color(color) |
@@ -288,13 +289,18 @@ def set_aa(self, aa): |
288 | 289 | return self.set_antialiased(aa) |
289 | 290 |
|
290 | 291 | def _set_edgecolor(self, color): |
| 292 | + set_hatch_color = True |
291 | 293 | if color is None: |
292 | 294 | if (mpl.rcParams['patch.force_edgecolor'] or |
293 | 295 | not self._fill or self._edge_default): |
294 | 296 | color = mpl.rcParams['patch.edgecolor'] |
295 | 297 | else: |
296 | 298 | color = 'none' |
| 299 | + set_hatch_color = False |
| 300 | + |
297 | 301 | self._edgecolor = colors.to_rgba(color, self._alpha) |
| 302 | + if set_hatch_color: |
| 303 | + self._hatch_color = self._edgecolor |
298 | 304 | self.stale = True |
299 | 305 |
|
300 | 306 | def set_edgecolor(self, color): |
@@ -545,6 +551,12 @@ def draw(self, renderer): |
545 | 551 |
|
546 | 552 | if self._hatch: |
547 | 553 | gc.set_hatch(self._hatch) |
| 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.") |
548 | 560 |
|
549 | 561 | if self.get_sketch_params() is not None: |
550 | 562 | gc.set_sketch_params(*self.get_sketch_params()) |
@@ -4286,6 +4298,13 @@ def draw(self, renderer): |
4286 | 4298 |
|
4287 | 4299 | if self._hatch: |
4288 | 4300 | gc.set_hatch(self._hatch) |
| 4301 | + if self._hatch_color is not None: |
| 4302 | + try: |
| 4303 | + gc.set_hatch_color(self._hatch_color) |
| 4304 | + except AttributeError: |
| 4305 | + # if we end up with a GC that does not have this method |
| 4306 | + warnings.warn("Your backend does not support setting the " |
| 4307 | + "hatch color.") |
4289 | 4308 |
|
4290 | 4309 | if self.get_sketch_params() is not None: |
4291 | 4310 | gc.set_sketch_params(*self.get_sketch_params()) |
|
0 commit comments