CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
mpl_axes_hist_fix Namespace Reference

Functions

def hist
 

Variables

 is_sequence_of_strings = cbook.is_sequence_of_strings
 
 is_string_like = cbook.is_string_like
 
 iterable = cbook.iterable
 

Function Documentation

def mpl_axes_hist_fix.hist (   self,
  x,
  bins = 10,
  range = None,
  normed = False,
  weights = None,
  cumulative = False,
  bottom = None,
  histtype = 'bar',
  align = 'mid',
  orientation = 'vertical',
  rwidth = None,
  log = False,
  color = None,
  label = None,
  kwargs 
)
call signature::

  hist(x, bins=10, range=None, normed=False, cumulative=False,
       bottom=None, histtype='bar', align='mid',
       orientation='vertical', rwidth=None, log=False, **kwargs)

Compute and draw the histogram of *x*. The return value is a
tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,
[*patches0*, *patches1*,...]) if the input contains multiple
data.

Multiple data can be provided via *x* as a list of datasets
of potentially different length ([*x0*, *x1*, ...]), or as
a 2-D ndarray in which each column is a dataset.  Note that
the ndarray form is transposed relative to the list form.

Masked arrays are not supported at present.

Keyword arguments:

  *bins*:
    Either an integer number of bins or a sequence giving the
    bins.  If *bins* is an integer, *bins* + 1 bin edges
    will be returned, consistent with :func:`numpy.histogram`
    for numpy version >= 1.3, and with the *new* = True argument
    in earlier versions.
    Unequally spaced bins are supported if *bins* is a sequence.

  *range*:
    The lower and upper range of the bins. Lower and upper outliers
    are ignored. If not provided, *range* is (x.min(), x.max()).
    Range has no effect if *bins* is a sequence.

    If *bins* is a sequence or *range* is specified, autoscaling
    is based on the specified bin range instead of the
    range of x.

  *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))

    .. Note:: Until numpy release 1.5, the underlying numpy
              histogram function was incorrect with *normed*=*True*
              if bin sizes were unequal.  MPL inherited that
              error.  It is now corrected within MPL when using
              earlier numpy versions

  *weights*
    An array of weights, of the same shape as *x*.  Each value in
    *x* only contributes its associated weight towards the bin
    count (instead of 1).  If *normed* is True, the weights are
    normalized, so that the integral of the density over the range
    remains 1.

  *cumulative*:
    If *True*, then a histogram is computed where each bin
    gives the counts in that bin plus all bins for smaller values.
    The last bin gives the total number of datapoints.  If *normed*
    is also *True* then the histogram is normalized such that the
    last bin equals 1. If *cumulative* evaluates to less than 0
    (e.g. -1), the direction of accumulation is reversed.  In this
    case, if *normed* is also *True*, then the histogram is normalized
    such that the first bin equals 1.

  *histtype*: [ 'bar' | 'barstacked' | 'step' | 'stepfilled' ]
    The type of histogram to draw.

      - 'bar' is a traditional bar-type histogram.  If multiple data
        are given the bars are aranged side by side.

      - 'barstacked' is a bar-type histogram where multiple
        data are stacked on top of each other.

      - 'step' generates a lineplot that is by default
        unfilled.

      - 'stepfilled' generates a lineplot that is by default
        filled.

  *align*: ['left' | 'mid' | 'right' ]
    Controls how the histogram is plotted.

      - 'left': bars are centered on the left bin edges.

      - 'mid': bars are centered between the bin edges.

      - 'right': bars are centered on the right bin edges.

  *orientation*: [ 'horizontal' | 'vertical' ]
    If 'horizontal', :func:`~matplotlib.pyplot.barh` will be
    used for bar-type histograms and the *bottom* kwarg will be
    the left edges.

  *rwidth*:
    The relative width of the bars as a fraction of the bin
    width.  If *None*, automatically compute the width. Ignored
    if *histtype* = 'step' or 'stepfilled'.

  *log*:
    If *True*, the histogram axis will be set to a log scale.
    If *log* is *True* and *x* is a 1D array, empty bins will
    be filtered out and only the non-empty (*n*, *bins*,
    *patches*) will be returned.

  *color*:
    Color spec or sequence of color specs, one per
    dataset.  Default (*None*) uses the standard line
    color sequence.

  *label*:
    String, or sequence of strings to match multiple
    datasets.  Bar charts yield multiple patches per
    dataset, but only the first gets the label, so
    that the legend command will work as expected::

        ax.hist(10+2*np.random.randn(1000), label='men')
        ax.hist(12+3*np.random.randn(1000), label='women', alpha=0.5)
        ax.legend()

kwargs are used to update the properties of the
:class:`~matplotlib.patches.Patch` instances returned by *hist*:

%(Patch)s

**Example:**

.. plot:: mpl_examples/pylab_examples/histogram_demo.py

Definition at line 18 of file mpl_axes_hist_fix.py.

Variable Documentation

mpl_axes_hist_fix.is_sequence_of_strings = cbook.is_sequence_of_strings

Definition at line 12 of file mpl_axes_hist_fix.py.

mpl_axes_hist_fix.is_string_like = cbook.is_string_like

Definition at line 11 of file mpl_axes_hist_fix.py.

mpl_axes_hist_fix.iterable = cbook.iterable

Definition at line 10 of file mpl_axes_hist_fix.py.