@@ -8320,18 +8320,18 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
8320
8320
hist_kwargs = dict (range = bin_range )
8321
8321
8322
8322
n = []
8323
- mlast = bottom
8323
+ mlast = None
8324
8324
for i in xrange (nx ):
8325
8325
# this will automatically overwrite bins,
8326
8326
# so that each histogram uses the same bins
8327
8327
m , bins = np .histogram (x [i ], bins , weights = w [i ], ** hist_kwargs )
8328
8328
m = m .astype (float ) # causes problems later if it's an int
8329
- if mlast is None :
8330
- mlast = np .zeros (len (bins )- 1 , m .dtype )
8331
8329
if normed and not stacked :
8332
8330
db = np .diff (bins )
8333
8331
m = (m .astype (float ) / db ) / m .sum ()
8334
8332
if stacked :
8333
+ if mlast is None :
8334
+ mlast = np .zeros (len (bins )- 1 , m .dtype )
8335
8335
m += mlast
8336
8336
mlast [:] = m
8337
8337
n .append (m )
@@ -8422,6 +8422,12 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
8422
8422
x [0 :2 * len (bins )- 1 :2 ], x [1 :2 * len (bins )- 1 :2 ] = bins , bins [:- 1 ]
8423
8423
x [2 * len (bins )- 1 :] = x [1 :2 * len (bins )- 1 ][::- 1 ]
8424
8424
8425
+ if bottom is None :
8426
+ bottom = np .zeros (len (bins )- 1 , np .float )
8427
+
8428
+ y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins ):2 ] = bottom , bottom
8429
+ y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
8430
+
8425
8431
if log :
8426
8432
if orientation == 'horizontal' :
8427
8433
self .set_xscale ('log' , nonposx = 'clip' )
@@ -8457,12 +8463,13 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
8457
8463
8458
8464
xvals , yvals = [], []
8459
8465
for m in n :
8460
- # starting point for drawing polygon
8461
- y [0 ] = y [1 ]
8462
- # top of the previous polygon becomes the bottom
8463
- y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
8466
+ if stacked :
8467
+ # starting point for drawing polygon
8468
+ y [0 ] = y [1 ]
8469
+ # top of the previous polygon becomes the bottom
8470
+ y [2 * len (bins )- 1 :] = y [1 :2 * len (bins )- 1 ][::- 1 ]
8464
8471
# set the top of this polygon
8465
- y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins )- 1 :2 ] = m , m
8472
+ y [1 :2 * len (bins )- 1 :2 ], y [2 :2 * len (bins ):2 ] = m + bottom , m + bottom
8466
8473
if log :
8467
8474
y [y < minimum ] = minimum
8468
8475
if orientation == 'horizontal' :
0 commit comments