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

Skip to content

Commit 3fb9b0c

Browse files
committed
removed _hatch_color param in favor of _hatchcolors
1 parent 8dc7e07 commit 3fb9b0c

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,12 @@ def _iter_collection(self, gc, path_ids, offsets, offset_trans, facecolors,
363363
N = max(Npaths, Noffsets)
364364
Nfacecolors = len(facecolors)
365365
Nedgecolors = len(edgecolors)
366+
Nhatchcolors = len(hatchcolors)
366367
Nlinewidths = len(linewidths)
367368
Nlinestyles = len(linestyles)
368369
Nurls = len(urls)
369370

370-
if (Nfacecolors == 0 and Nedgecolors == 0) or Npaths == 0:
371+
if (Nfacecolors == 0 and Nedgecolors == 0 and Nhatchcolors == 0) or Npaths == 0:
371372
return
372373

373374
gc0 = self.new_gc()
@@ -382,6 +383,7 @@ def cycle_or_default(seq, default=None):
382383
toffsets = cycle_or_default(offset_trans.transform(offsets), (0, 0))
383384
fcs = cycle_or_default(facecolors)
384385
ecs = cycle_or_default(edgecolors)
386+
hcs = cycle_or_default(hatchcolors)
385387
lws = cycle_or_default(linewidths)
386388
lss = cycle_or_default(linestyles)
387389
aas = cycle_or_default(antialiaseds)
@@ -390,8 +392,8 @@ def cycle_or_default(seq, default=None):
390392
if Nedgecolors == 0:
391393
gc0.set_linewidth(0.0)
392394

393-
for pathid, (xo, yo), fc, ec, lw, ls, aa, url in itertools.islice(
394-
zip(pathids, toffsets, fcs, ecs, lws, lss, aas, urls), N):
395+
for pathid, (xo, yo), fc, ec, hc, lw, ls, aa, url in itertools.islice(
396+
zip(pathids, toffsets, fcs, ecs, hcs, lws, lss, aas, urls), N):
395397
if not (np.isfinite(xo) and np.isfinite(yo)):
396398
continue
397399
if Nedgecolors:
@@ -403,6 +405,8 @@ def cycle_or_default(seq, default=None):
403405
gc0.set_linewidth(0)
404406
else:
405407
gc0.set_foreground(ec)
408+
if Nhatchcolors:
409+
gc0.set_hatch_color(hc)
406410
if fc is not None and len(fc) == 4 and fc[3] == 0:
407411
fc = None
408412
gc0.set_antialiased(aa)

lib/matplotlib/collections.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ def draw(self, renderer):
365365

366366
if self._hatch:
367367
gc.set_hatch(self._hatch)
368-
gc.set_hatch_color(self._hatch_color)
369368

370369
if self.get_sketch_params() is not None:
371370
gc.set_sketch_params(*self.get_sketch_params())
@@ -822,7 +821,6 @@ def _set_edgecolor(self, c):
822821
self._set_hatchcolor('black')
823822
else:
824823
self._hatchcolors = self._edgecolors
825-
self._hatch_color = self._hatchcolors[0]
826824
self.stale = True
827825

828826
def set_edgecolor(self, c):
@@ -851,15 +849,10 @@ def _set_hatchcolor(self, c):
851849
else:
852850
c = mpl.rcParams["patch.edgecolor"]
853851

854-
if not isinstance(c, str):
855-
if len(c) == 0:
856-
c = "black"
857-
else:
858-
if c in ('none', 'face'):
859-
c = "black"
852+
if isinstance(c, str) and c in ('none', 'face'):
853+
c = 'black'
860854

861855
self._hatchcolors = mcolors.to_rgba_array(c, self._alpha)
862-
self._hatch_color = self._hatchcolors[0]
863856
self.stale = True
864857

865858
def set_hatchcolor(self, c):
@@ -996,7 +989,6 @@ def update_from(self, other):
996989
self._pickradius = other._pickradius
997990
self._hatch = other._hatch
998991
self._hatchcolors = other._hatchcolors
999-
self._hatch_color = other._hatch_color
1000992

1001993
# update_from for scalarmappable
1002994
self._A = other._A

lib/matplotlib/legend_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,11 @@ def get_first(prop_array):
790790
# Directly set Patch color attributes (must be RGBA tuples).
791791
legend_handle._facecolor = first_color(orig_handle.get_facecolor())
792792
legend_handle._edgecolor = first_color(orig_handle.get_edgecolor())
793+
legend_handle._hatch_color = first_color(orig_handle.get_hatchcolor())
793794
legend_handle._original_facecolor = orig_handle._original_facecolor
794795
legend_handle._original_edgecolor = orig_handle._original_edgecolor
795796
legend_handle._fill = orig_handle.get_fill()
796797
legend_handle._hatch = orig_handle.get_hatch()
797-
# Hatch color is anomalous in having no getters and setters.
798-
legend_handle._hatch_color = orig_handle._hatch_color
799798
# Setters are fine for the remaining attributes.
800799
legend_handle.set_linewidth(get_first(orig_handle.get_linewidths()))
801800
legend_handle.set_linestyle(get_first(orig_handle.get_linestyles()))

0 commit comments

Comments
 (0)