@@ -6335,8 +6335,8 @@ def table(self, **kwargs):
63356335 @_preprocess_data (replace_names = ["x" , 'weights' ], label_namer = "x" )
63366336 def hist (self , x , bins = None , range = None , density = None , weights = None ,
63376337 cumulative = False , bottom = None , histtype = 'bar' , align = 'mid' ,
6338- orientation = 'vertical' , rwidth = None , log = False ,
6339- color = None , label = None , stacked = False , normed = None ,
6338+ orientation = 'vertical' , rwidth = None , log = False , color = None ,
6339+ edgecolor = None , label = None , stacked = False , normed = None ,
63406340 ** kwargs ):
63416341 """
63426342 Plot a histogram.
@@ -6494,6 +6494,12 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64946494
64956495 Default is ``None``
64966496
6497+ edgecolor : color or array_like of colors or None, optional
6498+ Color spec or sequence of color specs, one per dataset. Default
6499+ (``None``) :rc:`hist.edgecolor`. If that is ``None`` as well, the
6500+ default patch settings are used (:rc:`patch.edgecolor` and
6501+ :rc:`patch.force_edgecolor`).
6502+
64976503 label : str or None, optional
64986504 String, or sequence of strings to match multiple datasets. Bar
64996505 charts yield multiple patches per dataset, but only the first gets
@@ -6619,10 +6625,21 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
66196625 else :
66206626 color = mcolors .to_rgba_array (color )
66216627 if len (color ) != nx :
6622- error_message = (
6628+ raise ValueError (
66236629 "color kwarg must have one color per data set. %d data "
66246630 "sets and %d colors were provided" % (nx , len (color )))
6625- raise ValueError (error_message )
6631+
6632+ if edgecolor is None :
6633+ edgecolor = rcParams ['hist.edgecolor' ]
6634+ if edgecolor is None :
6635+ edgecolor = [None ] * nx
6636+ else :
6637+ edgecolor = mcolors .to_rgba_array (edgecolor )
6638+ if len (edgecolor ) != nx :
6639+ raise ValueError (
6640+ "edgecolor kwarg must have one color per data set. "
6641+ "%d data sets and %d colors were provided" % (
6642+ nx , len (edgecolor )))
66266643
66276644 # If bins are not specified either explicitly or via range,
66286645 # we need to figure out the range required for all datasets,
@@ -6715,7 +6732,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
67156732 _barfunc = self .bar
67166733 bottom_kwarg = 'bottom'
67176734
6718- for m , c in zip (tops , color ):
6735+ for m , c , ec in zip (tops , color , edgecolor ):
67196736 if bottom is None :
67206737 bottom = np .zeros (len (m ))
67216738 if stacked :
@@ -6724,7 +6741,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
67246741 height = m
67256742 patch = _barfunc (bins [:- 1 ]+ boffset , height , width ,
67266743 align = 'center' , log = log ,
6727- color = c , ** {bottom_kwarg : bottom })
6744+ color = c , edgecolor = ec ,
6745+ ** {bottom_kwarg : bottom })
67286746 patches .append (patch )
67296747 if stacked :
67306748 bottom [:] = m
@@ -6805,12 +6823,13 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
68056823 # add patches in reverse order so that when stacking,
68066824 # items lower in the stack are plotted on top of
68076825 # items higher in the stack
6808- for x , y , c in reversed (list (zip (xvals , yvals , color ))):
6826+ for x , y , c , ec in reversed (list (zip (xvals , yvals , color ,
6827+ edgecolor ))):
68096828 patches .append (self .fill (
68106829 x [:split ], y [:split ],
68116830 closed = True if fill else None ,
68126831 facecolor = c ,
6813- edgecolor = None if fill else c ,
6832+ edgecolor = ec if fill else c ,
68146833 fill = fill if fill else None ))
68156834 for patch_list in patches :
68166835 for patch in patch_list :
0 commit comments