Histogram without probability

The histogram example in the matpolotlib gallery is just what I want, except
instead of "probility" shown on the Y-axis, I want the number of items that
fall into each bin to be plotted. How do I do this? Here is my code:

        import numpy as np
        import matplotlib
        matplotlib.use('Agg')
        import matplotlib.pyplot as plt

        fig = plt.figure()
        ax = fig.add_subplot(111)

        x = self.data ## a list, such as [12.43, 34.24, 35.56, 465.3547, ]
        ax.hist(x, 60, normed=1, facecolor='green', alpha=0.75)

        ax.set_xlabel('Totals')
        ax.set_ylabel('Number of Users'))
        ax.set_xlim(0, 2000)
        ax.set_ylim(0, 0.003)
        ax.grid(True)

···

--
View this message in context: http://old.nabble.com/Histogram-without-probability-tp26781968p26781968.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

*normed*:
        If *True*, the first element of the return tuple will
        be the counts normalized to form a probability density, i.e.,
        ``n/(len(x)*dbin)``. In a probability density, the integral of
        the histogram should be 1; you can verify that with a
        trapezoidal integration of the probability density function::

          pdf, bins, patches = ax.hist(...)
          print np.sum(pdf * np.diff(bins))

So instead, pass normed=False (instead of normed=1) to the call to ax.hist.

Ryan

···

On Mon, Dec 14, 2009 at 7:22 PM, nbv4 <cp368202@...2769...> wrote:

The histogram example in the matpolotlib gallery is just what I want, except
instead of "probility" shown on the Y-axis, I want the number of items that
fall into each bin to be plotted. How do I do this? Here is my code:

   import numpy as np
   import matplotlib
   matplotlib\.use\(&#39;Agg&#39;\)
   import matplotlib\.pyplot as plt

   fig = plt\.figure\(\)
   ax = fig\.add\_subplot\(111\)

   x = self\.data \#\# a list, such as \[12\.43, 34\.24, 35\.56, 465\.3547, \]
   ax\.hist\(x, 60, normed=1, facecolor=&#39;green&#39;, alpha=0\.75\)

From the docstring for ax.hist:

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

nbv4 wrote:

The histogram example in the matpolotlib gallery is just what I want, except
instead of "probility" shown on the Y-axis, I want the number of items that
fall into each bin to be plotted. How do I do this? Here is my code:

        import numpy as np
        import matplotlib
        matplotlib.use('Agg')
        import matplotlib.pyplot as plt

        fig = plt.figure()
        ax = fig.add_subplot(111)

        x = self.data ## a list, such as [12.43, 34.24, 35.56, 465.3547, ]
        ax.hist(x, 60, normed=1, facecolor='green', alpha=0.75)

Leave out the "normed" kwarg, or set it to False (the default).

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.hist

···

        ax.set_xlabel('Totals')
        ax.set_ylabel('Number of Users'))
        ax.set_xlim(0, 2000)
        ax.set_ylim(0, 0.003)
        ax.grid(True)