@@ -6335,10 +6335,10 @@ 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+ label = None , stacked = False , normed = None ,
63406340 ** kwargs ):
6341- """
6341+ r """
63426342 Plot a histogram.
63436343
63446344 Compute and draw the histogram of *x*. The return value is a
@@ -6440,7 +6440,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64406440
64416441 Default is ``None``
64426442
6443- histtype : {'bar', 'barstacked', 'step', 'stepfilled'}, optional
6443+ histtype : {'bar', 'barstacked', 'step', 'stepfilled'}, optional
64446444 The type of histogram to draw.
64456445
64466446 - 'bar' is a traditional bar-type histogram. If multiple data
@@ -6488,12 +6488,6 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64886488
64896489 Default is ``False``
64906490
6491- color : color or array_like of colors or None, optional
6492- Color spec or sequence of color specs, one per dataset. Default
6493- (``None``) uses the standard line color sequence.
6494-
6495- Default is ``None``
6496-
64976491 label : str or None, optional
64986492 String, or sequence of strings to match multiple datasets. Bar
64996493 charts yield multiple patches per dataset, but only the first gets
@@ -6535,6 +6529,39 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65356529
65366530 Other Parameters
65376531 ----------------
6532+ color : color or array_like of colors or None, optional
6533+ The meaning of the parameter depends on *histtype*:
6534+
6535+ - For filled *histtype*\s ('bar', 'barstacked' and 'stepfilled'):
6536+
6537+ The facecolor of the bars. If providing multiple datasets to
6538+ *x*, there must be one color per dataset. If *None* the
6539+ standard line color sequence is used.
6540+
6541+ The *color* parameter is overridden if *facecolor* is given.
6542+
6543+ - For *histtype* 'step':
6544+
6545+ The linecolor of the step line. If None the standard line color
6546+ sequence is used.
6547+
6548+ Default: *None*
6549+
6550+ edgecolor : color or array_like of colors, optional
6551+ The edgecolor of the bars. If providing multiple datasets to
6552+ *x*, you can either pass a single edgecolor for all datasets or
6553+ one edgecolor per dataset. If not given, use :rc:`hist.edgecolor`.
6554+ If that is *None*, the default patch settings are used
6555+ (:rc:`patch.edgecolor` and :rc:`patch.force_edgecolor`).
6556+
6557+ Note: *edgecolor* is ignored for *histtype* 'step'. Use *color*
6558+ in this case.
6559+
6560+ linewidth : float, optional
6561+ The linewidth of the bar edges. If not given, use
6562+ :rc:`hist.linewidth`. If that is *None*, the default
6563+ :rc:`patch.linewidth` is used.
6564+
65386565 **kwargs : `~matplotlib.patches.Patch` properties
65396566
65406567 See also
@@ -6546,6 +6573,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65466573 .. [Notes section required for data comment. See #10189.]
65476574
65486575 """
6576+ kwargs = cbook .normalize_kwargs (kwargs , mpatches .Patch ._alias_map )
6577+
65496578 # Avoid shadowing the builtin.
65506579 bin_range = range
65516580 from builtins import range
@@ -6619,10 +6648,25 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
66196648 else :
66206649 color = mcolors .to_rgba_array (color )
66216650 if len (color ) != nx :
6622- error_message = (
6651+ raise ValueError (
66236652 "color kwarg must have one color per data set. %d data "
66246653 "sets and %d colors were provided" % (nx , len (color )))
6625- raise ValueError (error_message )
6654+
6655+ edgecolor = kwargs .pop ('edgecolor' , rcParams ['hist.edgecolor' ])
6656+ if edgecolor is None :
6657+ edgecolor = [None ] * nx
6658+ else :
6659+ edgecolor = mcolors .to_rgba_array (edgecolor )
6660+ if len (edgecolor ) == 1 :
6661+ edgecolor = np .repeat (nx , axis = 0 )
6662+ elif len (edgecolor ) != nx :
6663+ raise ValueError (
6664+ "edgecolor kwarg must have one color per data set. "
6665+ "%d data sets and %d colors were provided" % (
6666+ nx , len (edgecolor )))
6667+
6668+ if rcParams ['hist.linewidth' ] is not None :
6669+ kwargs .setdefault ('linewidth' , rcParams ['hist.linewidth' ])
66266670
66276671 # If bins are not specified either explicitly or via range,
66286672 # we need to figure out the range required for all datasets,
@@ -6715,7 +6759,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
67156759 _barfunc = self .bar
67166760 bottom_kwarg = 'bottom'
67176761
6718- for m , c in zip (tops , color ):
6762+ for m , c , ec in zip (tops , color , edgecolor ):
67196763 if bottom is None :
67206764 bottom = np .zeros (len (m ))
67216765 if stacked :
@@ -6724,7 +6768,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
67246768 height = m
67256769 patch = _barfunc (bins [:- 1 ]+ boffset , height , width ,
67266770 align = 'center' , log = log ,
6727- color = c , ** {bottom_kwarg : bottom })
6771+ color = c , edgecolor = ec ,
6772+ ** {bottom_kwarg : bottom })
67286773 patches .append (patch )
67296774 if stacked :
67306775 bottom [:] = m
@@ -6805,12 +6850,13 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
68056850 # add patches in reverse order so that when stacking,
68066851 # items lower in the stack are plotted on top of
68076852 # items higher in the stack
6808- for x , y , c in reversed (list (zip (xvals , yvals , color ))):
6853+ for x , y , c , ec in reversed (list (zip (xvals , yvals , color ,
6854+ edgecolor ))):
68096855 patches .append (self .fill (
68106856 x [:split ], y [:split ],
68116857 closed = True if fill else None ,
68126858 facecolor = c ,
6813- edgecolor = None if fill else c ,
6859+ edgecolor = ec if fill else c ,
68146860 fill = fill if fill else None ))
68156861 for patch_list in patches :
68166862 for patch in patch_list :
0 commit comments