@@ -6335,8 +6335,8 @@ def table(self, **kwargs):
6335
6335
@_preprocess_data (replace_names = ["x" , 'weights' ], label_namer = "x" )
6336
6336
def hist (self , x , bins = None , range = None , density = None , weights = None ,
6337
6337
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 ,
6340
6340
** kwargs ):
6341
6341
"""
6342
6342
Plot a histogram.
@@ -6494,6 +6494,12 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6494
6494
6495
6495
Default is ``None``
6496
6496
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
+
6497
6503
label : str or None, optional
6498
6504
String, or sequence of strings to match multiple datasets. Bar
6499
6505
charts yield multiple patches per dataset, but only the first gets
@@ -6546,6 +6552,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6546
6552
.. [Notes section required for data comment. See #10189.]
6547
6553
6548
6554
"""
6555
+ kwargs = cbook .normalize_kwargs (kwargs , mpatches .Patch ._alias_map )
6556
+
6549
6557
# Avoid shadowing the builtin.
6550
6558
bin_range = range
6551
6559
from builtins import range
@@ -6619,10 +6627,24 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6619
6627
else :
6620
6628
color = mcolors .to_rgba_array (color )
6621
6629
if len (color ) != nx :
6622
- error_message = (
6630
+ raise ValueError (
6623
6631
"color kwarg must have one color per data set. %d data "
6624
6632
"sets and %d colors were provided" % (nx , len (color )))
6625
- raise ValueError (error_message )
6633
+
6634
+ if edgecolor is None :
6635
+ edgecolor = rcParams ['hist.edgecolor' ]
6636
+ if edgecolor is None :
6637
+ edgecolor = [None ] * nx
6638
+ else :
6639
+ edgecolor = mcolors .to_rgba_array (edgecolor )
6640
+ if len (edgecolor ) != nx :
6641
+ raise ValueError (
6642
+ "edgecolor kwarg must have one color per data set. "
6643
+ "%d data sets and %d colors were provided" % (
6644
+ nx , len (edgecolor )))
6645
+
6646
+ if rcParams ['hist.linewidth' ] is not None :
6647
+ kwargs .setdefault ('linewidth' , rcParams ['hist.linewidth' ])
6626
6648
6627
6649
# If bins are not specified either explicitly or via range,
6628
6650
# we need to figure out the range required for all datasets,
@@ -6715,7 +6737,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6715
6737
_barfunc = self .bar
6716
6738
bottom_kwarg = 'bottom'
6717
6739
6718
- for m , c in zip (tops , color ):
6740
+ for m , c , ec in zip (tops , color , edgecolor ):
6719
6741
if bottom is None :
6720
6742
bottom = np .zeros (len (m ))
6721
6743
if stacked :
@@ -6724,7 +6746,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6724
6746
height = m
6725
6747
patch = _barfunc (bins [:- 1 ]+ boffset , height , width ,
6726
6748
align = 'center' , log = log ,
6727
- color = c , ** {bottom_kwarg : bottom })
6749
+ color = c , edgecolor = ec ,
6750
+ ** {bottom_kwarg : bottom })
6728
6751
patches .append (patch )
6729
6752
if stacked :
6730
6753
bottom [:] = m
@@ -6805,12 +6828,13 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6805
6828
# add patches in reverse order so that when stacking,
6806
6829
# items lower in the stack are plotted on top of
6807
6830
# items higher in the stack
6808
- for x , y , c in reversed (list (zip (xvals , yvals , color ))):
6831
+ for x , y , c , ec in reversed (list (zip (xvals , yvals , color ,
6832
+ edgecolor ))):
6809
6833
patches .append (self .fill (
6810
6834
x [:split ], y [:split ],
6811
6835
closed = True if fill else None ,
6812
6836
facecolor = c ,
6813
- edgecolor = None if fill else c ,
6837
+ edgecolor = ec if fill else c ,
6814
6838
fill = fill if fill else None ))
6815
6839
for patch_list in patches :
6816
6840
for patch in patch_list :
0 commit comments