[Numpy-discussion] NumPy Histogram for Tentative NumPy Tutorial Questions
Wayne Watson
sierra_mtnview at sbcglobal.net
Thu Nov 26 16:15:43 EST 2009
josef.pktd at gmail.com wrote:
> On Thu, Nov 26, 2009 at 2:44 PM, Wayne Watson
> <sierra_mtnview at sbcglobal.net> wrote:
>
>> I decided to try some example code from Subject.
>>
>> import numpy
>> import pylab
>> # Build a vector of 10000 normal deviates with variance 0.5^2 and mean 2
>> mu, sigma = 2, 0.5
>> v = numpy.random.normal(mu,sigma,10000)
>> # Plot a normalized histogram with 50 bins
>> pylab.hist(v, bins=50, normed=1) # matplotlib version (plot)
>> pylab.show()
>> # Compute the histogram with numpy and then plot it
>> (n, bins) = numpy.histogram(v, bins=50, normed=1) # NumPy version (no plot)
>> pylab.plot(.5*(bins[1:]+bins[:-1]), n)
>> pylab.show()
>>
>> After the histogram is displayed how do I get to the plot?
>> Where is histogram described in some detail? Normalized?
>> The histogram x-axis goes from 0 to 4.5. How does that happen?
>> Is v is two dimensional? What if it's one dimensional?
>>
>
> some quick answers:
>
> matlplotlib's histogram uses numpy histogram for the calculations,
> options are pretty well explained in the numpy docs, matplotlib has
> docs and examples for the display.
>
> If I use numpy.histogram, then, I think, I used bar plot for the
> display (scipy.stats.tutorial might also have an example where I had
> taken the pattern from somewhere else)
>
> numpy also has 2d and multidimensional histogram, but I don't know if
> the new 3d features of matplotlib can display them.
>
> Josef
>
>
Thanks. That link doesn't seem to exist. When you say docs, do you mean
some specific Python-like documentation? It looks like matplotlib has
some decent descriptions of their hist program. I'd still like to know
how one closes a graph and allows the program to continue. The above
program is supposed to do a plot after the histogram, but I do not see
one appear. If I press X to exit. It exits.
--
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/>
More information about the NumPy-Discussion
mailing list