@@ -8319,18 +8319,18 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
83198319 hist_kwargs = dict (range = bin_range )
83208320
83218321 n = []
8322- mlast = bottom
8322+ mlast = None
83238323 for i in xrange (nx ):
83248324 # this will automatically overwrite bins,
83258325 # so that each histogram uses the same bins
83268326 m , bins = np .histogram (x [i ], bins , weights = w [i ], ** hist_kwargs )
83278327 m = m .astype (float ) # causes problems later if it's an int
8328- if mlast is None :
8329- mlast = np .zeros (len (bins )- 1 , m .dtype )
83308328 if normed and not stacked :
83318329 db = np .diff (bins )
83328330 m = (m .astype (float ) / db ) / m .sum ()
83338331 if stacked :
8332+ if mlast is None :
8333+ mlast = np .zeros (len (bins )- 1 , m .dtype )
83348334 m += mlast
83358335 mlast [:] = m
83368336 n .append (m )
@@ -8421,6 +8421,12 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
84218421 x [0 :2 * len (bins )- 1 :2 ], x [1 :2 * len (bins )- 1 :2 ] = bins , bins [:- 1 ]
84228422 x [2 * len (bins )- 1 :] = x [1 :2 * len (bins )- 1 ][::- 1 ]
84238423
8424+ if bottom is None :
8425+ bottom = np .zeros (len (bins )- 1 , np .float )
8426+
8427+ y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins ):2 ] = bottom , bottom
8428+ y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
8429+
84248430 if log :
84258431 if orientation == 'horizontal' :
84268432 self .set_xscale ('log' , nonposx = 'clip' )
@@ -8456,12 +8462,13 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
84568462
84578463 xvals , yvals = [], []
84588464 for m in n :
8459- # starting point for drawing polygon
8460- y [0 ] = y [1 ]
8461- # top of the previous polygon becomes the bottom
8462- y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
8465+ if stacked :
8466+ # starting point for drawing polygon
8467+ y [0 ] = y [1 ]
8468+ # top of the previous polygon becomes the bottom
8469+ y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
84638470 # set the top of this polygon
8464- y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins )- 1 :2 ] = m , m
8471+ y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins ):2 ] = m + bottom , m + bottom
84658472 if log :
84668473 y [y < minimum ] = minimum
84678474 if orientation == 'horizontal' :
0 commit comments