@@ -6633,7 +6633,11 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6633
6633
6634
6634
if histtype .startswith ('bar' ):
6635
6635
6636
- totwidth = np .diff (bins )
6636
+ def _get_boffset (boffset ):
6637
+ if np .any (boffset ):
6638
+ return np .diff (boffset )
6639
+ else :
6640
+ return 0.0
6637
6641
6638
6642
if rwidth is not None :
6639
6643
dr = np .clip (rwidth , 0 , 1 )
@@ -6644,17 +6648,17 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6644
6648
dr = 1.0
6645
6649
6646
6650
if histtype == 'bar' and not stacked :
6647
- width = dr * totwidth / nx
6648
- dw = width
6649
- boffset = - 0.5 * dr * totwidth * (1 - 1 / nx )
6651
+ starts = dr * bins / nx
6652
+ dw = starts
6653
+ boffset = - 0.5 * dr * bins * (1 - 1 / nx )
6650
6654
elif histtype == 'barstacked' or stacked :
6651
- width = dr * totwidth
6655
+ starts = dr * bins
6652
6656
boffset , dw = 0.0 , 0.0
6653
6657
6654
6658
if align == 'mid' :
6655
- boffset += 0.5 * totwidth
6659
+ boffset += 0.5 * bins
6656
6660
elif align == 'right' :
6657
- boffset += totwidth
6661
+ boffset += bins
6658
6662
6659
6663
if orientation == 'horizontal' :
6660
6664
_barfunc = self .barh
@@ -6663,15 +6667,17 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6663
6667
_barfunc = self .bar
6664
6668
bottom_kwarg = 'bottom'
6665
6669
6670
+ width = np .diff (starts )
6671
+
6666
6672
for m , c in zip (tops , color ):
6667
6673
if bottom is None :
6668
6674
bottom = np .zeros (len (m ))
6669
6675
if stacked :
6670
6676
height = m - bottom
6671
6677
else :
6672
6678
height = m
6673
- bars = _barfunc (bins [:- 1 ]+ boffset , height , width ,
6674
- align = 'center' , log = log ,
6679
+ bars = _barfunc (bins [:- 1 ] + _get_boffset ( boffset ) , height ,
6680
+ width , align = 'center' , log = log ,
6675
6681
color = c , ** {bottom_kwarg : bottom })
6676
6682
patches .append (bars )
6677
6683
if stacked :
0 commit comments