## Re: [Matplotlib-users] Histogram creation question

 Re: [Matplotlib-users] Histogram creation question From: Alan G Isaac - 2005-12-21 23:15:57 ```In pylab: just choose the number of bins. Hope this helps. Alan Isaac >>> import pylab as P >>> help(P.hist) Help on function hist in module matplotlib.pylab: hist(*args, **kwargs) HIST(x, bins=3D10, normed=3D0, bottom=3D0, orientiation=3D'vertical', *= *kwargs) Compute the histogram of x. bins is either an integer number of bins or a sequence giving the bins. x are the data to be binned. The return values is (n, bins, patches) If normed is true, the first element of the return tuple will be the counts normalized to form a probability distribtion, ie, n/(len(x)*dbin) orientation =3D 'horizontal' | 'vertical'. If horizontal, barh will be used and the "bottom" kwarg will be the left. kwargs are used to update the properties of the hist bars Addition kwargs: hold =3D [True|False] overrides default hold state >>> ```

 [Matplotlib-users] Histogram creation question From: Peter Bowyer - 2005-12-21 23:09:21 ```Hi, I have a data set (number of dice thrown showing a particular number) and I'm trying to create a histogram of it. The data is stored in a text file, one trial per line, and I'm loading it using load(). Sample data: 12 17 8 12 11 16 It appears I need to group the data somehow into counts, eg: 8 : 1 9 : 0 10 : 0 11 : 1 12 : 2 and so on... Is there a way to do this in matplotlib or am I missing something about hist() or one of the other functions? Thanks, Peter ```
 Re: [Matplotlib-users] Histogram creation question From: Alan G Isaac - 2005-12-21 23:15:57 ```In pylab: just choose the number of bins. Hope this helps. Alan Isaac >>> import pylab as P >>> help(P.hist) Help on function hist in module matplotlib.pylab: hist(*args, **kwargs) HIST(x, bins=3D10, normed=3D0, bottom=3D0, orientiation=3D'vertical', *= *kwargs) Compute the histogram of x. bins is either an integer number of bins or a sequence giving the bins. x are the data to be binned. The return values is (n, bins, patches) If normed is true, the first element of the return tuple will be the counts normalized to form a probability distribtion, ie, n/(len(x)*dbin) orientation =3D 'horizontal' | 'vertical'. If horizontal, barh will be used and the "bottom" kwarg will be the left. kwargs are used to update the properties of the hist bars Addition kwargs: hold =3D [True|False] overrides default hold state >>> ```
 Re: [Matplotlib-users] Histogram creation question From: John Hunter - 2005-12-21 23:35:06 ```>>>>> "Alan" == Alan G Isaac writes: Alan> In pylab: just choose the number of bins. Hope this helps. Alan> Alan Isaac >>>> import pylab as P help(P.hist) Alan> Help on function hist in module matplotlib.pylab: If you know your data are integers, you might get nicer results by specifying the bins rather than autogenerating them by passing in number of bins. Eg for a 12 sided dice import matplotlib.numerix as nx bins = nx.arange(1,13) n,bins,patches = P.hist(throws, bins) JDH ```