@@ -5406,11 +5406,11 @@ def twiny(self):
5406
5406
#### Data analysis
5407
5407
5408
5408
5409
- def hist (self , x , bins = 10 , normed = 0 , bottom = None , histtype = 'bar' ,
5409
+ def hist (self , x , bins = 10 , normed = False , bottom = None , histtype = 'bar' ,
5410
5410
align = 'edge' , orientation = 'vertical' , width = None ,
5411
5411
log = False , ** kwargs ):
5412
5412
"""
5413
- HIST(x, bins=10, normed=0 , bottom=None, histtype='bar',
5413
+ HIST(x, bins=10, normed=False , bottom=None, histtype='bar',
5414
5414
align='edge', orientation='vertical', width=None,
5415
5415
log=False, **kwargs)
5416
5416
@@ -5449,40 +5449,35 @@ def hist(self, x, bins=10, normed=0, bottom=None, histtype='bar',
5449
5449
%(Rectangle)s
5450
5450
"""
5451
5451
if not self ._hold : self .cla ()
5452
- n , bins = np .histogram (x , bins , range = None , normed = normed )
5453
- if width is None :
5454
- if histtype == 'bar' :
5455
- width = 0.9 * (bins [1 ]- bins [0 ])
5456
- elif histtype == 'step' :
5457
- width = bins [1 ]- bins [0 ]
5458
- else :
5459
- raise ValueError , 'invalid histtype: %s' % histtype
5452
+ n , bins = np .histogram (x , bins , range = None ,
5453
+ normed = bool (normed ), new = True )
5460
5454
5461
5455
if histtype == 'bar' :
5456
+ if width is None :
5457
+ width = 0.9 * (bins [1 ]- bins [0 ])
5458
+
5462
5459
if orientation == 'horizontal' :
5463
- patches = self .barh (bins , n , height = width , left = bottom ,
5460
+ patches = self .barh (bins [: - 1 ] , n , height = width , left = bottom ,
5464
5461
align = align , log = log )
5465
5462
elif orientation == 'vertical' :
5466
- patches = self .bar (bins , n , width = width , bottom = bottom ,
5463
+ patches = self .bar (bins [: - 1 ] , n , width = width , bottom = bottom ,
5467
5464
align = align , log = log )
5468
5465
else :
5469
5466
raise ValueError , 'invalid orientation: %s' % orientation
5470
5467
5471
5468
elif histtype == 'step' :
5472
- binedges = np .concatenate ((bins ,bins [- 1 :]+ width ))
5469
+ x = np .zeros ( 2 * len (bins ), np .float_ )
5470
+ y = np .zeros ( 2 * len (bins ), np .float_ )
5471
+
5472
+ x [0 ::2 ], x [1 ::2 ] = bins , bins
5473
+ y [1 :- 1 :2 ], y [2 ::2 ] = n , n
5474
+
5473
5475
if align == 'center' :
5474
- binedges -= 0.5 * width
5475
- x = np .zeros ( 2 * len (binedges ), np .float_ )
5476
- y = np .zeros ( 2 * len (binedges ), np .float_ )
5476
+ x -= 0.5 * (bins [1 ]- bins [0 ])
5477
5477
5478
- x [0 :- 1 :2 ],x [1 ::2 ] = binedges , binedges
5479
- y [1 :- 1 :2 ],y [2 ::2 ] = n , n
5480
-
5481
5478
if orientation == 'horizontal' :
5482
5479
x ,y = y ,x
5483
- elif orientation == 'vertical' :
5484
- pass
5485
- else :
5480
+ elif orientation != 'vertical' :
5486
5481
raise ValueError , 'invalid orientation: %s' % orientation
5487
5482
patches = self .fill (x ,y )
5488
5483
else :
0 commit comments