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

Skip to content

Commit 018a748

Browse files
committed
minor fixes
1 parent 256d735 commit 018a748

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/matplotlib/collections.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def __init__(self, *,
105105
facecolor.
106106
facecolors : :mpltype:`color` or list of colors, default: :rc:`patch.facecolor`
107107
Face color for each patch making up the collection.
108+
hatchcolors : :mpltype:`color` or list of colors, default: :rc:`hatch.color`
109+
Hatch color for each patch making up the collection. The special
110+
value 'edge' can be passed to make the hatchcolor match the
111+
edgecolor.
108112
linewidths : float or list of floats, default: :rc:`patch.linewidth`
109113
Line width for each patch making up the collection.
110114
linestyles : str or tuple or list thereof, default: 'solid'
@@ -754,7 +758,7 @@ def _get_default_antialiased(self):
754758

755759
def set_color(self, c):
756760
"""
757-
Set both the edgecolor and the facecolor.
761+
Sets the edgecolor, facecolor and hatchcolor.
758762
759763
Parameters
760764
----------
@@ -767,6 +771,7 @@ def set_color(self, c):
767771
"""
768772
self.set_facecolor(c)
769773
self.set_edgecolor(c)
774+
self.set_hatchcolor(c)
770775

771776
def _get_default_facecolor(self):
772777
# This may be overridden in a subclass.
@@ -811,7 +816,7 @@ def _get_default_edgecolor(self):
811816

812817
def get_hatchcolor(self):
813818
if cbook._str_equal(self._hatchcolors, 'edge'):
814-
if self.get_edgecolor().size == 0:
819+
if len(self.get_edgecolor()) == 0:
815820
return mpl.colors.to_rgba_array(self._get_default_edgecolor(),
816821
self._alpha)
817822
return self.get_edgecolor()
@@ -852,7 +857,7 @@ def set_edgecolor(self, c):
852857

853858
def _set_hatchcolor(self, c):
854859
c = mpl._val_or_rc(c, 'hatch.color')
855-
if c == 'edge':
860+
if cbook._str_equal(c, 'edge'):
856861
self._hatchcolors = 'edge'
857862
else:
858863
self._hatchcolors = mcolors.to_rgba_array(c, self._alpha)
@@ -868,8 +873,6 @@ def set_hatchcolor(self, c):
868873
The collection hatchcolor(s). If a sequence, the patches cycle
869874
through it.
870875
"""
871-
if cbook._str_equal(c, 'edge'):
872-
c = 'edge'
873876
self._original_hatchcolor = c
874877
self._set_hatchcolor(c)
875878

@@ -888,6 +891,7 @@ def set_alpha(self, alpha):
888891
artist.Artist._set_alpha_for_array(self, alpha)
889892
self._set_facecolor(self._original_facecolor)
890893
self._set_edgecolor(self._original_edgecolor)
894+
self._set_hatchcolor(self._original_hatchcolor)
891895

892896
set_alpha.__doc__ = artist.Artist._set_alpha_for_array.__doc__
893897

0 commit comments

Comments
 (0)