[Numpy-discussion] Producing a Histogram When Bins Are Known

Sebastian sebas0 at gmail.com
Fri Nov 27 21:05:20 EST 2009


Hi Chris, yeah there should, try the following:
import numpy
import matplotlib.pyplot as pylab
regards

On Fri, Nov 27, 2009 at 8:47 PM, Wayne Watson
<sierra_mtnview at sbcglobal.net>wrote:

> I tried this and it put ranges on y from 0 to 0.45 and x from 5 to 50.
>
> import numpy as np
> import pylab
>
> v = np.array([20, 15,10,30, 50, 30, 20, 25, 10])
> #Plot a normalized histogram
> print np.linspace(0,50,10)
> pylab.hist(v, normed=1, bins=np.linspace(0,9,10), range=(0,100))
> pylab.show()
>
> I  added the two imports. I got a fig error on the first line.
> import pylab
> import numpy
>
> Shouldn't there by a pylab.Show in there?
>
> ax = fig.add_subplot(1,1,1)
> pylab.title(r'\Large  BCG NO radio distribution $ \rm{TITLE}$')
> n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
>
> range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)),
> normed=1, facecolor='y', alpha=0.5)
> ax.set_xlabel(r'\Large$ \rm{values}$')
> ax.set_ylabel(r'\Large Delatavalue/Value')
>
>
> gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
>
> gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value))
> pylab.plot(gausx,gaus, color='red', lw=2)
> ax.set_xlim(-1.5, 1.5)
> ax.grid(True)
>
> Sebastian wrote:
> > Did you try using the parameter range?
> > I do something like this.
> > regards
> >
> >     ax = fig.add_subplot(1,1,1)
> >     pylab.title(r'\Large  BCG NO radio distribution $ \rm{TITLE}$')
> >     n, bins, patches = pylab.hist(values, bins=math.sqrt(len(values)),
> >
> range=(numpy.mean(values)-3*scientificstat.standardDeviation(values),numpy.mean(values)+3*scientificstat.standardDeviation(values)),
> >     normed=1, facecolor='y', alpha=0.5)
> >     ax.set_xlabel(r'\Large$ \rm{values}$')
> >     ax.set_ylabel(r'\Large Delatavalue/Value')
> >
> >
> gausx=numpy.arange(numpy.mean(Value)-3*scientificstat.standardDeviation(Value),numpy.mean(Value)+3*scientificstat.standardDeviation(bpty_plt),0.1)
> >
> gaus=normpdf(gausx,numpy.mean(Value),scientificstat.standardDeviation(Value))
> >     pylab.plot(gausx,gaus, color='red', lw=2)
> >     ax.set_xlim(-1.5, 1.5)
> >     ax.grid(True)
> >
> >
> > On Fri, Nov 27, 2009 at 4:38 PM, Christopher Barker
> > <Chris.Barker at noaa.gov <mailto:Chris.Barker at noaa.gov>> wrote:
> >
> >     josef.pktd at gmail.com <mailto:josef.pktd at gmail.com> wrote:
> >     > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold
> >     <jsseabold at gmail.com <mailto:jsseabold at gmail.com>> wrote:
> >
> >     >>  This kind of info might be useful to other newcomers
> >     >> somewhere...  <http://www.scipy.org/History_of_SciPy>?  Thoughts
> on
> >     >> posting this on the wiki here?
> >     >
> >     > I also agree. It will improve with the newly redesigned website
> >     for scipy.org <http://scipy.org>
> >     > However, I cannot find the link right now for the development
> >     version of
> >     > the new website.
> >
> >     Feel free to crib whatever you want from my post for that -- or
> >     suggest
> >     a place for me to put it, and I'll do it. I'm just not sure where it
> >     should go at this point.
> >
> >     -Chris
> >
> >
> >     --
> >     Christopher Barker, Ph.D.
> >     Oceanographer
> >
> >     Emergency Response Division
> >     NOAA/NOS/OR&R            (206) 526-6959   voice
> >     7600 Sand Point Way NE   (206) 526-6329   fax
> >     Seattle, WA  98115       (206) 526-6317   main reception
> >
> >     Chris.Barker at noaa.gov <mailto:Chris.Barker at noaa.gov>
> >     _______________________________________________
> >     NumPy-Discussion mailing list
> >     NumPy-Discussion at scipy.org <mailto:NumPy-Discussion at scipy.org>
> >     http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
>
> --
>           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>
>             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
>              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet
>
>                   350 350 350 350 350 350 350 350 350 350
>                     Make the number famous. See 350.org
>            The major event has passed, but keep the number alive.
>
>                    Web Page: <www.speckledwithstars.net/>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20091128/b1a53f0e/attachment.html>


More information about the NumPy-Discussion mailing list