Plotting histograms

Theerasak Photha hanumizzle at gmail.com
Tue Oct 17 06:05:03 CEST 2006


On 16 Oct 2006 20:49:10 -0700, amitsoni.1984 at gmail.com
<amitsoni.1984 at gmail.com> wrote:
> hi, I have some values(say from -a to a) stored in a vector and I want
> to plot a histogram for those values. How can I get it done in python.
> I have installed and imported the Matplotlib package but on executing
> the code
> [N,x]=hist(eig, 10) # make a histogram
>  I am getting an error saying   "NameError: name 'hist' is not
> defined".

Use the statement 'from pylab import *' in the beginning of your program.

Others, of course, may find it more tasteful and Pythonic to do:

[N,x]=pylab.hist(eig, 10)

i.e., prefix it with the package name. Wouldn't want to clutter the
global namespace of your program after all.

Good luck with it then. I think I see a reference to advanced linear
algebra with 'eig' (Eigen-?) and I'm sure you understand that better
than I. :)

-- Theerasak



More information about the Python-list mailing list