@@ -5416,9 +5416,9 @@ def twiny(self):
54165416 #### Data analysis
54175417
54185418
5419- def hist (self , x , bins = 10 , normed = False , bottom = None , histtype = 'bar' ,
5420- align = 'edge' , orientation = 'vertical ' , width = None ,
5421- log = False , ** kwargs ):
5419+ def hist (self , x , bins = 10 , normed = False , cumulative = False ,
5420+ bottom = None , histtype = 'bar ' , align = 'edge' ,
5421+ orientation = 'vertical' , width = None , log = False , ** kwargs ):
54225422 """
54235423 HIST(x, bins=10, normed=False, bottom=None, histtype='bar',
54245424 align='edge', orientation='vertical', width=None,
@@ -5439,6 +5439,12 @@ def hist(self, x, bins=10, normed=False, bottom=None, histtype='bar',
54395439 pdf, bins, patches = ax.hist(...)
54405440 print np.trapz(pdf, bins)
54415441
5442+ If cumulative is True then histogram is computed where each bin
5443+ gives the counts in that bin plus all bins for smaller values.
5444+ The last bins gives the total number of datapoints. If normed is
5445+ also True then the histogram is normalized such that the last bin
5446+ equals one (assuming equally spaced bins).
5447+
54425448 histtype = 'bar' | 'step'. The type of histogram to draw.
54435449 'bar' is a traditional bar-type histogram, 'step' generates
54445450 a lineplot.
@@ -5461,6 +5467,12 @@ def hist(self, x, bins=10, normed=False, bottom=None, histtype='bar',
54615467 if not self ._hold : self .cla ()
54625468 n , bins = np .histogram (x , bins , range = None ,
54635469 normed = bool (normed ), new = True )
5470+
5471+ if cumulative :
5472+ n = n .cumsum ()
5473+ if normed :
5474+ # normalize to 1
5475+ n *= (bins [1 ]- bins [0 ])
54645476
54655477 if histtype == 'bar' :
54665478 if width is None :
0 commit comments