[EMAIL PROTECTED] 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". > > Is there any other way to plot histograms over a given range?
>>> # create random vector ... from random import randrange >>> a = 5 >>> v = [randrange(-a, a+1) for i in xrange(100)] >>> >>> # print histogram ... for i in range(-a, a+1): ... print "%+d %s" % (i, '*' * v.count(i)) ... -5 ********* -4 ***** -3 ***** -2 ********** -1 ********** +0 ***** +1 ************ +2 ******* +3 ***** +4 ******************** +5 ************ :) -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list