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

josef.pktd@gmai... josef.pktd@gmai...
Fri Nov 27 21:01:22 CST 2009

On Fri, Nov 27, 2009 at 9:44 PM, Wayne Watson
<sierra_mtnview@sbcglobal.net> wrote:
> Joseph,
> That got it by the fig problem but there is yet another one. value is
> not defined on the very long line:
> range = ...
>    Wayne

(values is the data array, ... no idea about scientificstat.standardDeviation)

Sebastian's example is only part of a larger script that defines many
of the variables and functions that are used.

If you are not yet familiar with these examples, maybe you look at the
self contained examples in the matplotlib docs. At least that's what I
do when I only have a rough idea about what graph I want to do but
don't know how to do it with matplotlib. I usually just copy a likely
looking candidate and change it until it (almost)  produces what I
want.
For example look at histogram examples in

http://matplotlib.sourceforge.net/examples/index.html

Josef

> josef.pktd@gmail.com wrote:
>> On Fri, Nov 27, 2009 at 9:05 PM, Sebastian <sebas0@gmail.com> wrote:
>>
>> ...
>> you need to create a figure, before you can use it
>>
>> fig = pylab.figure()
>>
>> Josef
>>
>>
>>>> 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@noaa.gov <mailto:Chris.Barker@noaa.gov>> wrote:
>>>>>
>>>>>     josef.pktd@gmail.com <mailto:josef.pktd@gmail.com> wrote:
>>>>>     > On Fri, Nov 27, 2009 at 12:57 PM, Skipper Seabold
>>>>>     <jsseabold@gmail.com <mailto:jsseabold@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@noaa.gov <mailto:Chris.Barker@noaa.gov>
>>>>>     _______________________________________________
>>>>>     NumPy-Discussion mailing list
>>>>>     NumPy-Discussion@scipy.org <mailto:NumPy-Discussion@scipy.org>
>>>>>     http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> NumPy-Discussion mailing list
>>>>> NumPy-Discussion@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@scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>>
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>>
>>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@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@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>