Hi all,

In my latest post, I wanted to use the mpl.hist() function in a different way, i.e.:

x = datalist
bins= 100
hist(x,bins,normed=0)    #returns a tupple (n,bins,patches)

Instead of ploting the number of counts n, I wanted to plot the relative percentage of counts, i.e. n/len(x). I can't really use the option normed=1 which returns n/(len(x)*dbin). In the axes.py module, this would simply mean adding an argument e.g. relpercent = 1. I added the code line to show how this could be done (in major cap). If this is useful, how could it be modified in the distribution ?


    def hist(self, x, bins=10, RELPERCENT = 1, normed=0, bottom=None,
             align='edge', orientation='vertical', width=None,
             log=False, **kwargs):
        """

        if not self._hold: self.cla()
        n, bins = npy.histogram(x, bins, range=None, normed=normed)
        IF NOT NORMED AND RELPERCENT: N = N/FLOAT(LEN(X))
        if width is None: width = 0.9*(bins[1]-bins[0])
        if orientation == 'horizontal':
            patches = self.barh(bins, n, height=width, left=bottom,
                                align=align, log=log)
        elif orientation == 'vertical':
            patches = self.bar(bins, n, width=width, bottom=bottom,
                                align=align, log=log)
        else:
            raise ValueError, 'invalid orientation: %s' % orientation
        for p in patches:
            p.update(kwargs)
        return n, bins, cbook.silent_list('Patch', patches)



Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail