@@ -5245,7 +5245,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
52455245 hist_kwargs = dict (range = bin_range )
52465246
52475247 n = []
5248- mlast = bottom
5248+ mlast = None
52495249 for i in xrange (nx ):
52505250 # this will automatically overwrite bins,
52515251 # so that each histogram uses the same bins
@@ -5257,6 +5257,8 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
52575257 db = np .diff (bins )
52585258 m = (m .astype (float ) / db ) / m .sum ()
52595259 if stacked :
5260+ if mlast is None :
5261+ mlast = np .zeros (len (bins )- 1 , m .dtype )
52605262 m += mlast
52615263 mlast [:] = m
52625264 n .append (m )
@@ -5347,6 +5349,12 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
53475349 x [0 :2 * len (bins )- 1 :2 ], x [1 :2 * len (bins )- 1 :2 ] = bins , bins [:- 1 ]
53485350 x [2 * len (bins )- 1 :] = x [1 :2 * len (bins )- 1 ][::- 1 ]
53495351
5352+ if bottom is None :
5353+ bottom = np .zeros (len (bins )- 1 , np .float )
5354+
5355+ y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins ):2 ] = bottom , bottom
5356+ y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
5357+
53505358 if log :
53515359 if orientation == 'horizontal' :
53525360 self .set_xscale ('log' , nonposx = 'clip' )
@@ -5382,12 +5390,13 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
53825390
53835391 xvals , yvals = [], []
53845392 for m in n :
5385- # starting point for drawing polygon
5386- y [0 ] = y [1 ]
5387- # top of the previous polygon becomes the bottom
5388- y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
5393+ if stacked :
5394+ # starting point for drawing polygon
5395+ y [0 ] = y [1 ]
5396+ # top of the previous polygon becomes the bottom
5397+ y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
53895398 # set the top of this polygon
5390- y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins )- 1 :2 ] = m , m
5399+ y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins ):2 ] = m + bottom , m + bottom
53915400 if log :
53925401 y [y < minimum ] = minimum
53935402 if orientation == 'horizontal' :
0 commit comments