Hi!
You could also use the bar method and do the histogram with numpy:
import numpy as n
import pylab as p
foo = n.random.normal(size=100)
p.hist(foo, 20)
p.twinx()
counts, bins = n.histogram(foo, 20)
counts = counts.astype(float)/len(foo)
width = (bins[1]-bins[0]) * .9
p.bar(bins ,counts, width=width, fc='r')
Cheers! Bernhard
On Fri, Feb 22, 2008 at 4:08 PM, Auré Gourrier <[EMAIL PROTECTED]>
wrote:
> 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<http://fr.rd.yahoo.com/mail/mail_taglines/trueswitch/SIG=11gshn0bu/**http%3A%2F%2Fwww.trueswitch.com%2Fyahoo-fr%2F>vers
> Yahoo! Mail
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users