warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>return np.vander(*args, **kwargs)<EOL>

*X* = vander(*x*, *N* = *None*)

The Vandermonde matrix of vector *x*.  The *i*-th column of *X* is the
the *i*-th power of *x*.  *N* is the maximum power to compute; if *N* is
*None* it defaults to len(*x*).


if self.dataLim is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>x, y = self.asarrays()<EOL>self.dataLim.update_numerix(x, y, True)<EOL>

Update the *datalim* in the current data in the fifo.


raise NotImplementedError('<STR_LIT>')<EOL>


self._xa = np.zeros((nmax,), np.float_)<EOL>self._ya = np.zeros((nmax,), np.float_)<EOL>self._xs = np.zeros((nmax,), np.float_)<EOL>self._ys = np.zeros((nmax,), np.float_)<EOL>self._ind = <NUM_LIT:0><EOL>self._nmax = nmax<EOL>self.dataLim = None<EOL>self.callbackd = {}<EOL>


return np.hanning(len(x))*x<EOL>

return x times the hanning window of len(x)


return np.sum(np.absolute(a))<EOL>

Return the *l1* norm of *a*, flattened out.

Implemented as a separate function (not a call to :func:`norm` for speed).


res, = np.nonzero(np.ravel(condition))<EOL>return res<EOL>

Return the indices where ravel(condition) is true


def cohere(x, y, NFFT=<NUM_LIT>, Fs=<NUM_LIT:2>, detrend=detrend_none, window=window_hanning,<EOL>noverlap=<NUM_LIT:0>, pad_to=None, sides='<STR_LIT:default>', scale_by_freq=None):

if len(x)<<NUM_LIT:2>*NFFT:<EOL><INDENT>raise ValueError(_coh_error)<EOL><DEDENT>Pxx, f = psd(x, NFFT, Fs, detrend, window, noverlap, pad_to, sides,<EOL>scale_by_freq)<EOL>Pyy, f = psd(y, NFFT, Fs, detrend, window, noverlap, pad_to, sides,<EOL>scale_by_freq)<EOL>Pxy, f = csd(x, y, NFFT, Fs, detrend, window, noverlap, pad_to, sides,<EOL>scale_by_freq)<EOL>Cxy = np.divide(np.absolute(Pxy)**<NUM_LIT:2>, Pxx*Pyy)<EOL>Cxy.shape = (len(f),)<EOL>return Cxy, f<EOL>

The coherence between *x* and *y*.  Coherence is the normalized
cross spectral density:

.. math::

    C_{xy} = \\frac{|P_{xy}|^2}{P_{xx}P_{yy}}

*x*, *y*
    Array or sequence containing the data
%(PSD)s
The return value is the tuple (*Cxy*, *f*), where *f* are the
frequencies of the coherence vector. For cohere, scaling the
individual densities by the sampling frequency has no effect, since
the factors cancel out.

.. seealso::
    :func:`psd` and :func:`csd`:
        For information about the methods used to compute
        :math:`P_{xy}`, :math:`P_{xx}` and :math:`P_{yy}`.


return x - x.mean()<EOL>


w = np.empty((n,), dtype=np.float_)<EOL>w[:] = <NUM_LIT:1.0>/n<EOL>return np.convolve(x, w, mode='<STR_LIT>')<EOL>

Compute the len(*n*) moving average of *x*.


Deprecated - see :func:`numpy.linalg.norm`


def fromfunction_kw(function, dimensions, **kwargs):

warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>return np.fromfunction(function, dimensions, **kwargs)<EOL>

Drop-in replacement for :func:`numpy.fromfunction`.

Allows passing keyword arguments to the desired function.

Call it as (keywords are optional)::

  fromfunction_kw(MyFunction, dimensions, keywords)

The function ``MyFunction`` is responsible for handling the
dictionary of keywords it will receive.


if cbook.is_string_like(x):<EOL><INDENT>return False<EOL><DEDENT>try: b = np.isinf(x)<EOL>except NotImplementedError: return False<EOL>except TypeError: return False<EOL>else: return b<EOL>


warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>return np.convolve(x,y,mode)<EOL>


d = x-y<EOL>return np.sqrt(np.dot(d,d))<EOL>


N = len(x)<EOL>if N%<NUM_LIT:2> != <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>' +'<STR_LIT>')<EOL><DEDENT>dx = x[<NUM_LIT:1>]-x[<NUM_LIT:0>]<EOL>f = <NUM_LIT:1>/(N*dx)*np.arange(-N/<NUM_LIT:2>, N/<NUM_LIT:2>, np.float_)<EOL>ind = np.concatenate([np.arange(N/<NUM_LIT:2>, N, int),<EOL>np.arange(<NUM_LIT:0>, N/<NUM_LIT:2>, int)])<EOL>df = f[<NUM_LIT:1>]-f[<NUM_LIT:0>]<EOL>cfl = exp(-gamma*np.absolute(<NUM_LIT:2>*pi*f)**alpha)<EOL>px = np.fft.fft(np.take(cfl,ind)*df).astype(np.float_)<EOL>return np.take(px, ind)<EOL>

Returm the levy pdf evaluated at *x* for params *gamma*, *alpha*


def cohere_pairs( X, ij, NFFT=<NUM_LIT>, Fs=<NUM_LIT:2>, detrend=detrend_none,<EOL>window=window_hanning, noverlap=<NUM_LIT:0>,<EOL>preferSpeedOverMemory=True,<EOL>progressCallback=donothing_callback,<EOL>returnPxx=False):

numRows, numCols = X.shape<EOL>if numRows < NFFT:<EOL><INDENT>tmp = X<EOL>X = np.zeros( (NFFT, numCols), X.dtype)<EOL>X[:numRows,:] = tmp<EOL>del tmp<EOL><DEDENT>numRows, numCols = X.shape<EOL>seen = {}<EOL>for i,j in ij:<EOL><INDENT>seen[i]=<NUM_LIT:1>; seen[j] = <NUM_LIT:1><EOL><DEDENT>allColumns = list(seen.keys())<EOL>Ncols = len(allColumns)<EOL>del seen<EOL>if np.iscomplexobj(X): numFreqs = NFFT<EOL>else: numFreqs = NFFT//<NUM_LIT:2>+<NUM_LIT:1><EOL>if cbook.iterable(window):<EOL><INDENT>assert(len(window) == NFFT)<EOL>windowVals = window<EOL><DEDENT>else:<EOL><INDENT>windowVals = window(np.ones((NFFT,), typecode(X)))<EOL><DEDENT>ind = list(range(<NUM_LIT:0>, numRows-NFFT+<NUM_LIT:1>, NFFT-noverlap))<EOL>numSlices = len(ind)<EOL>FFTSlices = {}<EOL>FFTConjSlices = {}<EOL>Pxx = {}<EOL>slices = list(range(numSlices))<EOL>normVal = norm(windowVals)**<NUM_LIT:2><EOL>for iCol in allColumns:<EOL><INDENT>progressCallback(i/Ncols, '<STR_LIT>')<EOL>Slices = np.zeros( (numSlices,numFreqs), dtype=np.complex_)<EOL>for iSlice in slices:<EOL><INDENT>thisSlice = X[ind[iSlice]:ind[iSlice]+NFFT, iCol]<EOL>thisSlice = windowVals*detrend(thisSlice)<EOL>Slices[iSlice,:] = fft(thisSlice)[:numFreqs]<EOL><DEDENT>FFTSlices[iCol] = Slices<EOL>if preferSpeedOverMemory:<EOL><INDENT>FFTConjSlices[iCol] = conjugate(Slices)<EOL><DEDENT>Pxx[iCol] = np.divide(np.mean(absolute(Slices)**<NUM_LIT:2>), normVal)<EOL><DEDENT>del Slices, ind, windowVals<EOL>Cxy = {}<EOL>Phase = {}<EOL>count = <NUM_LIT:0><EOL>N = len(ij)<EOL>for i,j in ij:<EOL><INDENT>count +=<NUM_LIT:1><EOL>if count%<NUM_LIT:10>==<NUM_LIT:0>:<EOL><INDENT>progressCallback(count/N, '<STR_LIT>')<EOL><DEDENT>if preferSpeedOverMemory:<EOL><INDENT>Pxy = FFTSlices[i] * FFTConjSlices[j]<EOL><DEDENT>else:<EOL><INDENT>Pxy = FFTSlices[i] * np.conjugate(FFTSlices[j])<EOL><DEDENT>if numSlices><NUM_LIT:1>: Pxy = np.mean(Pxy)<EOL>Pxy = np.divide(Pxy, normVal)<EOL>Cxy[(i,j)] = np.divide(np.absolute(Pxy)**<NUM_LIT:2>, Pxx[i]*Pxx[j])<EOL>Phase[(i,j)] =  np.arctan2(Pxy.imag, Pxy.real)<EOL><DEDENT>freqs = Fs/NFFT*np.arange(numFreqs)<EOL>if returnPxx:<EOL><INDENT>return Cxy, Phase, freqs, Pxx<EOL><DEDENT>else:<EOL><INDENT>return Cxy, Phase, freqs<EOL><DEDENT>

Cxy, Phase, freqs = cohere_pairs(X, ij, ...)

Compute the coherence for all pairs in *ij*.  *X* is a
(*numSamples*, *numCols*) numpy array.  *ij* is a list of tuples
(*i*, *j*).  Each tuple is a pair of indexes into the columns of *X*
for which you want to compute coherence.  For example, if *X* has 64
columns, and you want to compute all nonredundant pairs, define *ij*
as::

  ij = []
  for i in range(64):
      for j in range(i+1,64):
          ij.append( (i, j) )

The other function arguments, except for *preferSpeedOverMemory*
(see below), are explained in the help string of :func:`psd`.

Return value is a tuple (*Cxy*, *Phase*, *freqs*).

  - *Cxy*: a dictionary of (*i*, *j*) tuples -> coherence vector for that
    pair.  I.e., ``Cxy[(i,j)] = cohere(X[:,i], X[:,j])``.  Number of
    dictionary keys is ``len(ij)``.

  - *Phase*: a dictionary of phases of the cross spectral density at
    each frequency for each pair.  The keys are ``(i,j)``.

  - *freqs*: a vector of frequencies, equal in length to either
    the coherence or phase vectors for any (*i*, *j*) key..  Eg,
    to make a coherence Bode plot::

      subplot(211)
      plot( freqs, Cxy[(12,19)])
      subplot(212)
      plot( freqs, Phase[(12,19)])

For a large number of pairs, :func:`cohere_pairs` can be much more
efficient than just calling :func:`cohere` for each pair, because
it caches most of the intensive computations.  If *N* is the
number of pairs, this function is O(N) for most of the heavy
lifting, whereas calling cohere for each pair is
O(N\N{SUPERSCRIPT TWO}).  However, because of the caching, it is
also more memory intensive, making 2 additional complex arrays
with approximately the same number of elements as *X*.

The parameter *preferSpeedOverMemory*, if *False*, limits the
caching by only making one, rather than two, complex cache arrays.
This is useful if memory becomes critical.  Even when
*preferSpeedOverMemory* is *False*, :func:`cohere_pairs` will
still give significant performace gains over calling
:func:`cohere` for each pair, and will use subtantially less
memory than if *preferSpeedOverMemory* is *True*.  In my tests
with a (43000, 64) array over all non-redundant pairs,
*preferSpeedOverMemory* = *True* delivered a 33% performace boost
on a 1.7GHZ Athlon with 512MB RAM compared with
*preferSpeedOverMemory* = *False*.  But both solutions were more
than 10x faster than naievly crunching all possible pairs through
cohere.

.. seealso::
    :file:`test/cohere_pairs_test.py` in the src tree:
        For an example script that shows that this
        :func:`cohere_pairs` and :func:`cohere` give the same
        results for a given pair.


names = set(names)<EOL>Nr = len(rec)<EOL>newdtype = np.dtype([(name, rec.dtype[name]) for name in rec.dtype.names<EOL>if name not in names])<EOL>newrec = np.empty(Nr, dtype=newdtype)<EOL>for field in newdtype.names:<EOL><INDENT>newrec[field] = rec[field]<EOL><DEDENT>return rec_view(newrec)<EOL>

Return a new numpy record array with fields in *names* dropped.


def binary_repr(number, max_length = <NUM_LIT>):

<EOL>shifts = list(map (operator.rshift, max_length * [number],list(range(max_length - <NUM_LIT:1>, -<NUM_LIT:1>, -<NUM_LIT:1>))))<EOL>digits = list(map (operator.mod, shifts, max_length * [<NUM_LIT:2>]))<EOL>if not digits.count (<NUM_LIT:1>): return <NUM_LIT:0><EOL>digits = digits [digits.index (<NUM_LIT:1>):]<EOL>return '<STR_LIT>'.join (map (repr, digits)).replace('<STR_LIT:L>','<STR_LIT>')<EOL>

Return the binary representation of the input *number* as a
string.

This is more efficient than using :func:`base_repr` with base 2.

Increase the value of max_length for very large numbers. Note that
on 32-bit machines, 2**1023 is the largest integer power of 2
which can be converted to a Python float.


return longest_contiguous_ones(x)<EOL>


try: Ny = len(y0)<EOL>except TypeError:<EOL><INDENT>yout = np.zeros( (len(t),), np.float_)<EOL><DEDENT>else:<EOL><INDENT>yout = np.zeros( (len(t), Ny), np.float_)<EOL><DEDENT>yout[<NUM_LIT:0>] = y0<EOL>i = <NUM_LIT:0><EOL>for i in np.arange(len(t)-<NUM_LIT:1>):<EOL><INDENT>thist = t[i]<EOL>dt = t[i+<NUM_LIT:1>] - thist<EOL>dt2 = dt/<NUM_LIT><EOL>y0 = yout[i]<EOL>k1 = np.asarray(derivs(y0, thist))<EOL>k2 = np.asarray(derivs(y0 + dt2*k1, thist+dt2))<EOL>k3 = np.asarray(derivs(y0 + dt2*k2, thist+dt2))<EOL>k4 = np.asarray(derivs(y0 + dt*k3, thist+dt))<EOL>yout[i+<NUM_LIT:1>] = y0 + dt/<NUM_LIT>*(k1 + <NUM_LIT:2>*k2 + <NUM_LIT:2>*k3 + k4)<EOL><DEDENT>return yout<EOL>

Integrate 1D or ND system of ODEs using 4-th order Runge-Kutta.
This is a toy implementation which may be useful if you find
yourself stranded on a system w/o scipy.  Otherwise use
:func:`scipy.integrate`.

*y0*
    initial state vector

*t*
    sample times

*derivs*
    returns the derivative of the system and has the
    signature ``dy = derivs(yi, ti)``

Example 1 ::

    ## 2D system

    def derivs6(x,t):
        d1 =  x[0] + 2*x[1]
        d2 =  -3*x[0] + 4*x[1]
        return (d1, d2)
    dt = 0.0005
    t = arange(0.0, 2.0, dt)
    y0 = (1,2)
    yout = rk4(derivs6, y0, t)

Example 2::

    ## 1D system
    alpha = 2
    def derivs(x,t):
        return -alpha*x + exp(-t)

    y0 = 1
    yout = rk4(derivs, y0, t)

If you have access to scipy, you should probably be using the
scipy.integrate tools rather than this function.


<EOL>x=np.asarray(x, np.float_)<EOL>y=np.asarray(y, np.float_)<EOL>assert x.shape == y.shape<EOL>N=len(y)<EOL>if yp is None:<EOL><INDENT>yp = slopes(x,y)<EOL><DEDENT>else:<EOL><INDENT>yp=np.asarray(yp, np.float_)<EOL><DEDENT>xi=np.asarray(xi, np.float_)<EOL>yi=np.zeros(xi.shape, np.float_)<EOL>dx = x[<NUM_LIT:1>:] - x[:-<NUM_LIT:1>]<EOL>dy = y[<NUM_LIT:1>:] - y[:-<NUM_LIT:1>]<EOL>s = dy/dx  <EOL>idx = np.searchsorted(x[<NUM_LIT:1>:-<NUM_LIT:1>], xi)<EOL>sidx = s.take(idx)<EOL>xidx = x.take(idx)<EOL>yidx = y.take(idx)<EOL>xidxp1 = x.take(idx+<NUM_LIT:1>)<EOL>yo = yidx + sidx * (xi - xidx)<EOL>dy1 = (yp.take(idx)- sidx) * (xi - xidx)       <EOL>dy2 = (yp.take(idx+<NUM_LIT:1>)-sidx) * (xi - xidxp1) <EOL>dy1dy2 = dy1*dy2<EOL>yi = yo + dy1dy2 * np.choose(np.array(np.sign(dy1dy2), np.int32)+<NUM_LIT:1>,<EOL>((<NUM_LIT:2>*xi-xidx-xidxp1)/((dy1-dy2)*(xidxp1-xidx)),<EOL><NUM_LIT:0.0>,<EOL><NUM_LIT:1>/(dy1+dy2),))<EOL>return yi<EOL>

Given data vectors *x* and *y*, the slope vector *yp* and a new
abscissa vector *xi*, the function :func:`stineman_interp` uses
Stineman interpolation to calculate a vector *yi* corresponding to
*xi*.

Here's an example that generates a coarse sine curve, then
interpolates over a finer abscissa::

  x = linspace(0,2*pi,20);  y = sin(x); yp = cos(x)
  xi = linspace(0,2*pi,40);
  yi = stineman_interp(xi,x,y,yp);
  plot(x,y,'o',xi,yi)

The interpolation method is described in the article A
CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russell
W. Stineman. The article appeared in the July 1980 issue of
Creative Computing with a note from the editor stating that while
they were:

  not an academic journal but once in a while something serious
  and original comes in adding that this was
  "apparently a real solution" to a well known problem.

For *yp* = *None*, the routine automatically determines the slopes
using the :func:`slopes` routine.

*x* is assumed to be sorted in increasing order.

For values ``xi[j] < x[0]`` or ``xi[j] > x[-1]``, the routine
tries an extrapolation.  The relevance of the data obtained from
this, of course, is questionable...

Original implementation by Halldor Bjornsson, Icelandic
Meteorolocial Office, March 2006 halldor at vedur.is

Completely reworked and optimized for Python by Norbert Nemec,
Institute of Theoretical Physics, University or Regensburg, April
2006 Norbert.Nemec at physik.uni-regensburg.de


X = np.diff( X, axis=<NUM_LIT:0> )<EOL>return vector_lengths(X,axis=<NUM_LIT:1>)<EOL>

Computes the distance between a set of successive points in *N* dimensions.

Where *X* is an *M* x *N* array or matrix.  The distances between
successive rows is computed.  Distance is the standard Euclidean
distance.


warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>return np.diag(diag)<EOL>

Return square diagonal matrix whose non-zero elements are given by the
input array.


raise NotImplementedError('<STR_LIT>')<EOL>

Deprecated - needs clean room implementation


def rec_append_fields(rec, names, arrs, dtypes=None):

if (not cbook.is_string_like(names) and cbook.iterable(names)and len(names) and cbook.is_string_like(names[<NUM_LIT:0>])):<EOL><INDENT>if len(names) != len(arrs):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>else: <EOL><INDENT>names = [names]<EOL>arrs = [arrs]<EOL><DEDENT>arrs = list(map(np.asarray, arrs))<EOL>if dtypes is None:<EOL><INDENT>dtypes = [a.dtype for a in arrs]<EOL><DEDENT>elif not cbook.iterable(dtypes):<EOL><INDENT>dtypes = [dtypes]<EOL><DEDENT>if len(arrs) != len(dtypes):<EOL><INDENT>if len(dtypes) == <NUM_LIT:1>:<EOL><INDENT>dtypes = dtypes * len(arrs)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>newdtype = np.dtype(rec.dtype.descr + list(zip(names, dtypes)))<EOL>newrec = np.empty(rec.shape, dtype=newdtype)<EOL>for field in rec.dtype.fields:<EOL><INDENT>newrec[field] = rec[field]<EOL><DEDENT>for name, arr in zip(names, arrs):<EOL><INDENT>newrec[name] = arr<EOL><DEDENT>return rec_view(newrec)<EOL>

Return a new record array with field names populated with data
from arrays in *arrs*.  If appending a single field, then *names*,
*arrs* and *dtypes* do not have to be lists. They can just be the
values themselves.


if self._ind<self._nmax:<EOL><INDENT>return self._xs[:self._ind], self._ys[:self._ind]<EOL><DEDENT>ind = self._ind % self._nmax<EOL>self._xa[:self._nmax-ind] = self._xs[ind:]<EOL>self._xa[self._nmax-ind:] = self._xs[:ind]<EOL>self._ya[:self._nmax-ind] = self._ys[ind:]<EOL>self._ya[self._nmax-ind:] = self._ys[:ind]<EOL>return self._xa, self._ya<EOL>

Return *x* and *y* as arrays; their length will be the len of
data added or *nmax*.


p = np.asarray(p, np.float_)<EOL>s0 = np.asarray(s0, np.float_)<EOL>s1 = np.asarray(s1, np.float_)<EOL>v = s1 - s0<EOL>w = p - s0<EOL>c1 = np.dot(w,v);<EOL>if ( c1 <= <NUM_LIT:0> ):<EOL><INDENT>return dist(p, s0);<EOL><DEDENT>c2 = np.dot(v,v)<EOL>if ( c2 <= c1 ):<EOL><INDENT>return dist(p, s1);<EOL><DEDENT>b = c1 / c2<EOL>pb = s0 + b * v;<EOL>return dist(p, pb)<EOL>

Get the distance of a point to a segment.

  *p*, *s0*, *s1* are *xy* sequences

This algorithm from
http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm#Distance%20to%20Ray%20or%20Segment


(x1, y1), (x2, y2) = s1<EOL>(x3, y3), (x4, y4) = s2<EOL>den = ((y4-y3) * (x2-x1)) - ((x4-x3)*(y2-y1))<EOL>n1 = ((x4-x3) * (y1-y3)) - ((y4-y3)*(x1-x3))<EOL>n2 = ((x2-x1) * (y1-y3)) - ((y2-y1)*(x1-x3))<EOL>if den == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>u1 = n1/den<EOL>u2 = n2/den<EOL>return <NUM_LIT:0.0> <= u1 <= <NUM_LIT:1.0> and <NUM_LIT:0.0> <= u2 <= <NUM_LIT:1.0><EOL>

Return *True* if *s1* and *s2* intersect.
*s1* and *s2* are defined as::

  s1: (x1, y1), (x2, y2)
  s2: (x3, y3), (x4, y4)


in_region = None<EOL>boundaries = []<EOL>for i, val in enumerate(mask):<EOL><INDENT>if in_region is None and val:<EOL><INDENT>in_region = i<EOL><DEDENT>elif in_region is not None and not val:<EOL><INDENT>boundaries.append((in_region, i))<EOL>in_region = None<EOL><DEDENT><DEDENT>if in_region is not None:<EOL><INDENT>boundaries.append((in_region, i+<NUM_LIT:1>))<EOL><DEDENT>return boundaries<EOL>

return a list of (ind0, ind1) such that mask[ind0:ind1].all() is
True and we cover all such regions

TODO: this is a pure python implementation which probably has a much faster numpy impl


return np.sqrt(np.mean(np.absolute(a)**<NUM_LIT:2>))<EOL>

Return the root mean square of all the elements of *a*, flattened out.


if self._ind==<NUM_LIT:0>: return None, None<EOL>ind = (self._ind-<NUM_LIT:1>) % self._nmax<EOL>return self._xs[ind], self._ys[ind]<EOL>

Get the last *x*, *y* or *None*.  *None* if no data set.


def rec2csv(r, fname, delimiter='<STR_LIT:U+002C>', formatd=None, missing='<STR_LIT>',<EOL>missingd=None):

if missingd is None:<EOL><INDENT>missingd = dict()<EOL><DEDENT>def with_mask(func):<EOL><INDENT>def newfunc(val, mask, mval):<EOL><INDENT>if mask:<EOL><INDENT>return mval<EOL><DEDENT>else:<EOL><INDENT>return func(val)<EOL><DEDENT><DEDENT>return newfunc<EOL><DEDENT>formatd = get_formatd(r, formatd)<EOL>funcs = []<EOL>for i, name in enumerate(r.dtype.names):<EOL><INDENT>funcs.append(with_mask(csvformat_factory(formatd[name]).tostr))<EOL><DEDENT>fh, opened = cbook.to_filehandle(fname, '<STR_LIT:w>', return_opened=True)<EOL>writer = csv.writer(fh, delimiter=delimiter)<EOL>header = r.dtype.names<EOL>writer.writerow(header)<EOL>mvals = []<EOL>for name in header:<EOL><INDENT>mvals.append(missingd.get(name, missing))<EOL><DEDENT>ismasked = False<EOL>if len(r):<EOL><INDENT>row = r[<NUM_LIT:0>]<EOL>ismasked = hasattr(row, '<STR_LIT>')<EOL><DEDENT>for row in r:<EOL><INDENT>if ismasked:<EOL><INDENT>row, rowmask = row.item(), row._fieldmask.item()<EOL><DEDENT>else:<EOL><INDENT>rowmask = [False] * len(row)<EOL><DEDENT>writer.writerow([func(val, mask, mval) for func, val, mask, mval<EOL>in zip(funcs, row, rowmask, mvals)])<EOL><DEDENT>if opened:<EOL><INDENT>fh.close()<EOL><DEDENT>

Save the data from numpy recarray *r* into a
comma-/space-/tab-delimited file.  The record array dtype names
will be used for column headers.

*fname*: can be a filename or a file handle.  Support for gzipped
  files is automatic, if the filename ends in '.gz'

.. seealso::
    :func:`csv2rec`:
        For information about *missing* and *missingd*, which can
        be used to fill in masked values into your CSV file.


STINEMAN_INTERP Well behaved data interpolation.  Given data
vectors X and Y, the slope vector YP and a new abscissa vector XI
the function stineman_interp(xi,x,y,yp) uses Stineman
interpolation to calculate a vector YI corresponding to XI.

Here's an example that generates a coarse sine curve, then
interpolates over a finer abscissa:

  x = linspace(0,2*pi,20);  y = sin(x); yp = cos(x)
  xi = linspace(0,2*pi,40);
  yi = stineman_interp(xi,x,y,yp);
  plot(x,y,'o',xi,yi)

The interpolation method is described in the article A
CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russell
W. Stineman. The article appeared in the July 1980 issue of
Creative Computing with a note from the editor stating that while
they were

  not an academic journal but once in a while something serious
  and original comes in adding that this was
  "apparently a real solution" to a well known problem.

For yp=None, the routine automatically determines the slopes using
the "slopes" routine.

X is assumed to be sorted in increasing order

For values xi[j] < x[0] or xi[j] > x[-1], the routine tries a
extrapolation.  The relevance of the data obtained from this, of
course, questionable...

original implementation by Halldor Bjornsson, Icelandic
Meteorolocial Office, March 2006 halldor at vedur.is

completely reworked and optimized for Python by Norbert Nemec,
Institute of Theoretical Physics, University or Regensburg, April
2006 Norbert.Nemec at physik.uni-regensburg.de


return np.prod(X.shape)==np.max(X.shape)<EOL>

Like the Matlab (TM) function with the same name, returns *True*
if the supplied numpy array or matrix *X* looks like a vector,
meaning it has a one non-singleton axis (i.e., it can have
multiple axes, but all must have length 1, except for one of
them).

If you just want to see if the array has 1 axis, use X.ndim == 1.


return np.array(list(map(fn,*args)))<EOL>

amap(function, sequence[, sequence, ...]) -> array.

Works like :func:`map`, but it returns an array.  This is just a
convenient shorthand for ``numpy.array(map(...))``.


try:<EOL><INDENT>bin_n = binary_repr(x)[<NUM_LIT:1>:]<EOL><DEDENT>except (AssertionError,TypeError):<EOL><INDENT>return math.log(x)/ln2<EOL><DEDENT>else:<EOL><INDENT>if '<STR_LIT:1>' in bin_n:<EOL><INDENT>return math.log(x)/ln2<EOL><DEDENT>else:<EOL><INDENT>return len(bin_n)<EOL><DEDENT><DEDENT>

Return the log(*x*) in base 2.

This is a _slow_ function but which is guaranteed to return the correct
integer value if the input is an integer exact power of 2.


if cbook.is_string_like(x):<EOL><INDENT>return False<EOL><DEDENT>try: b = np.isnan(x)<EOL>except NotImplementedError: return False<EOL>except TypeError: return False<EOL>else: return b<EOL>


x = np.ravel(x)<EOL>if len(x)==<NUM_LIT:0>:<EOL><INDENT>return np.array([])<EOL><DEDENT>ind = (x==<NUM_LIT:0>).nonzero()[<NUM_LIT:0>]<EOL>if len(ind)==<NUM_LIT:0>:<EOL><INDENT>return np.arange(len(x))<EOL><DEDENT>if len(ind)==len(x):<EOL><INDENT>return np.array([])<EOL><DEDENT>y = np.zeros( (len(x)+<NUM_LIT:2>,), x.dtype)<EOL>y[<NUM_LIT:1>:-<NUM_LIT:1>] = x<EOL>dif = np.diff(y)<EOL>up = (dif ==  <NUM_LIT:1>).nonzero()[<NUM_LIT:0>];<EOL>dn = (dif == -<NUM_LIT:1>).nonzero()[<NUM_LIT:0>];<EOL>i = (dn-up == max(dn - up)).nonzero()[<NUM_LIT:0>][<NUM_LIT:0>]<EOL>ind = np.arange(up[i], dn[i])<EOL>return ind<EOL>

Return the indices of the longest stretch of contiguous ones in *x*,
assuming *x* is a vector of zeros and ones.  If there are two
equally long stretches, pick the first.


U,s,v = np.linalg.svd(P)<EOL>varEach = s**<NUM_LIT:2>/P.shape[<NUM_LIT:1>]<EOL>totVar = varEach.sum()<EOL>fracVar = varEach/totVar<EOL>ind = slice((fracVar>=frac).sum())<EOL>Trans = U[:,ind].transpose()<EOL>Pcomponents = np.dot(Trans,P)<EOL>return Pcomponents, Trans, fracVar[ind]<EOL>

Compute the principal components of *P*.  *P* is a (*numVars*,
*numObs*) array.  *frac* is the minimum fraction of variance that a
component must contain to be included.

Return value is a tuple of the form (*Pcomponents*, *Trans*,
*fracVar*) where:

  - *Pcomponents* : a (numVars, numObs) array

  - *Trans* : the weights matrix, ie, *Pcomponents* = *Trans* *
     *P*

  - *fracVar* : the fraction of the variance accounted for by each
     component returned

A similar function of the same name was in the Matlab (TM)
R13 Neural Network Toolbox but is not found in later versions;
its successor seems to be called "processpcs".


return poly_between(xs, ys, xmin)<EOL>

given a arrays *xs* and *ys*, return the vertices of a polygon
that has a scalar lower bound *ymin* and an upper bound at the *ys*.

intended for use with Axes.fill, eg::

  xv, yv = poly_below(0, x, y)
  ax.fill(xv, yv)


M = np.asarray(M, np.float_)<EOL>if dim:<EOL><INDENT>M = (M - M.mean(axis=<NUM_LIT:0>)) / M.std(axis=<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>M = (M - M.mean(axis=<NUM_LIT:1>)[:,np.newaxis])<EOL>M = M / M.std(axis=<NUM_LIT:1>)[:,np.newaxis]<EOL><DEDENT>return M<EOL>

Return the matrix *M* with each row having zero mean and unit std.

If *dim* = 1 operate on columns instead of rows.  (*dim* is
opposite to the numpy axis kwarg.)


if not self._hold: self.cla()<EOL>d = {'<STR_LIT>': kwargs.pop( '<STR_LIT>', <NUM_LIT:10>),<EOL>'<STR_LIT>': kwargs.pop( '<STR_LIT>', None),<EOL>}<EOL>self.set_xscale('<STR_LIT>', **d)<EOL>b =  self._hold<EOL>self._hold = True <EOL>l = self.plot(*args, **kwargs)<EOL>self._hold = b    <EOL>return l<EOL>

call signature::

  semilogx(*args, **kwargs)

Make a plot with log scaling on the *x* axis.

:func:`semilogx` supports all the keyword arguments of
:func:`~matplotlib.pyplot.plot` and
:meth:`matplotlib.axes.Axes.set_xscale`.

Notable keyword arguments:

  *basex*: scalar > 1
    base of the *x* logarithm

  *subsx*: [ None | sequence ]
    The location of the minor xticks; *None* defaults to
    autosubs, which depend on the number of decades in the
    plot; see :meth:`~matplotlib.axes.Axes.set_xscale` for
    details.

The remaining valid kwargs are
:class:`~matplotlib.lines.Line2D` properties:

%(Line2D)s

.. seealso::
    :meth:`loglog`:
        For example code and figure


ymin, ymax = self.dataLim.intervaly<EOL>if ymin==<NUM_LIT:0.>:<EOL><INDENT>dmax = today = datetime.date.today()<EOL>dmin = today-datetime.timedelta(days=<NUM_LIT:10>)<EOL>self._process_unit_info(ydata=(dmin, dmax))<EOL>dmin, dmax = self.convert_yunits([dmin, dmax])<EOL>self.viewLim.intervaly = dmin, dmax<EOL>self.dataLim.intervaly = dmin, dmax<EOL><DEDENT>locator = self.yaxis.get_major_locator()<EOL>if not isinstance(locator, mdates.DateLocator):<EOL><INDENT>locator = mdates.AutoDateLocator(tz)<EOL>self.yaxis.set_major_locator(locator)<EOL><DEDENT>if self.viewLim.intervaly[<NUM_LIT:0>]==<NUM_LIT:0.>:<EOL><INDENT>self.viewLim.intervaly = tuple(self.dataLim.intervaly)<EOL><DEDENT>locator.refresh()<EOL>formatter = self.xaxis.get_major_formatter()<EOL>if not isinstance(formatter, mdates.DateFormatter):<EOL><INDENT>formatter = mdates.AutoDateFormatter(locator, tz)<EOL>self.yaxis.set_major_formatter(formatter)<EOL><DEDENT>

Sets up y-axis ticks and labels that treat the y data as dates.

        *tz* is the time zone to use in labeling dates.  Defaults to rc value.


<EOL>self.dataLim.ignore(True)<EOL>self.ignore_existing_data_limits = True<EOL>for line in self.lines:<EOL><INDENT>self._update_line_limits(line)<EOL><DEDENT>for p in self.patches:<EOL><INDENT>self._update_patch_limits(p)<EOL><DEDENT>

recompute the data limits based on current artists


return self.legend_<EOL>

Return the legend.Legend instance, or None if no legend is defined


def set_xticks(self, ticks, minor=False):

return self.xaxis.set_ticks(ticks, minor=minor)<EOL>

Set the x ticks with list of *ticks*

ACCEPTS: sequence of floats


if not self._hold: self.cla()<EOL>alpha = kwargs.pop('<STR_LIT>', <NUM_LIT:1.0>)<EOL>norm = kwargs.pop('<STR_LIT>', None)<EOL>cmap = kwargs.pop('<STR_LIT>', None)<EOL>vmin = kwargs.pop('<STR_LIT>', None)<EOL>vmax = kwargs.pop('<STR_LIT>', None)<EOL>shading = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>X, Y, C = self._pcolorargs('<STR_LIT>', *args)<EOL>Ny, Nx = X.shape<EOL>C = ma.asarray(C)<EOL>X = ma.asarray(X)<EOL>Y = ma.asarray(Y)<EOL>mask = ma.getmaskarray(X)+ma.getmaskarray(Y)<EOL>xymask = mask[<NUM_LIT:0>:-<NUM_LIT:1>,<NUM_LIT:0>:-<NUM_LIT:1>]+mask[<NUM_LIT:1>:,<NUM_LIT:1>:]+mask[<NUM_LIT:0>:-<NUM_LIT:1>,<NUM_LIT:1>:]+mask[<NUM_LIT:1>:,<NUM_LIT:0>:-<NUM_LIT:1>]<EOL>mask = ma.getmaskarray(C)[<NUM_LIT:0>:Ny-<NUM_LIT:1>,<NUM_LIT:0>:Nx-<NUM_LIT:1>]+xymask<EOL>newaxis = np.newaxis<EOL>compress = np.compress<EOL>ravelmask = (mask==<NUM_LIT:0>).ravel()<EOL>X1 = compress(ravelmask, ma.filled(X[<NUM_LIT:0>:-<NUM_LIT:1>,<NUM_LIT:0>:-<NUM_LIT:1>]).ravel())<EOL>Y1 = compress(ravelmask, ma.filled(Y[<NUM_LIT:0>:-<NUM_LIT:1>,<NUM_LIT:0>:-<NUM_LIT:1>]).ravel())<EOL>X2 = compress(ravelmask, ma.filled(X[<NUM_LIT:1>:,<NUM_LIT:0>:-<NUM_LIT:1>]).ravel())<EOL>Y2 = compress(ravelmask, ma.filled(Y[<NUM_LIT:1>:,<NUM_LIT:0>:-<NUM_LIT:1>]).ravel())<EOL>X3 = compress(ravelmask, ma.filled(X[<NUM_LIT:1>:,<NUM_LIT:1>:]).ravel())<EOL>Y3 = compress(ravelmask, ma.filled(Y[<NUM_LIT:1>:,<NUM_LIT:1>:]).ravel())<EOL>X4 = compress(ravelmask, ma.filled(X[<NUM_LIT:0>:-<NUM_LIT:1>,<NUM_LIT:1>:]).ravel())<EOL>Y4 = compress(ravelmask, ma.filled(Y[<NUM_LIT:0>:-<NUM_LIT:1>,<NUM_LIT:1>:]).ravel())<EOL>npoly = len(X1)<EOL>xy = np.concatenate((X1[:,newaxis], Y1[:,newaxis],<EOL>X2[:,newaxis], Y2[:,newaxis],<EOL>X3[:,newaxis], Y3[:,newaxis],<EOL>X4[:,newaxis], Y4[:,newaxis],<EOL>X1[:,newaxis], Y1[:,newaxis]),<EOL>axis=<NUM_LIT:1>)<EOL>verts = xy.reshape((npoly, <NUM_LIT:5>, <NUM_LIT:2>))<EOL>C = compress(ravelmask, ma.filled(C[<NUM_LIT:0>:Ny-<NUM_LIT:1>,<NUM_LIT:0>:Nx-<NUM_LIT:1>]).ravel())<EOL>if shading == '<STR_LIT>':<EOL><INDENT>edgecolors = (<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:1>),<EOL>linewidths = (<NUM_LIT>,)<EOL><DEDENT>else:<EOL><INDENT>edgecolors = '<STR_LIT>'<EOL>linewidths = (<NUM_LIT:1.0>,)<EOL><DEDENT>kwargs.setdefault('<STR_LIT>', edgecolors)<EOL>kwargs.setdefault('<STR_LIT>', (<NUM_LIT:0>,))<EOL>kwargs.setdefault('<STR_LIT>', linewidths)<EOL>collection = mcoll.PolyCollection(verts, **kwargs)<EOL>collection.set_alpha(alpha)<EOL>collection.set_array(C)<EOL>if norm is not None: assert(isinstance(norm, mcolors.Normalize))<EOL>if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))<EOL>collection.set_cmap(cmap)<EOL>collection.set_norm(norm)<EOL>if vmin is not None or vmax is not None:<EOL><INDENT>collection.set_clim(vmin, vmax)<EOL><DEDENT>else:<EOL><INDENT>collection.autoscale_None()<EOL><DEDENT>self.grid(False)<EOL>x = X.compressed()<EOL>y = Y.compressed()<EOL>minx = np.amin(x)<EOL>maxx = np.amax(x)<EOL>miny = np.amin(y)<EOL>maxy = np.amax(y)<EOL>corners = (minx, miny), (maxx, maxy)<EOL>self.update_datalim( corners)<EOL>self.autoscale_view()<EOL>self.add_collection(collection)<EOL>return collection<EOL>

call signatures::

  pcolor(C, **kwargs)
  pcolor(X, Y, C, **kwargs)

Create a pseudocolor plot of a 2-D array.

*C* is the array of color values.

*X* and *Y*, if given, specify the (*x*, *y*) coordinates of
the colored quadrilaterals; the quadrilateral for C[i,j] has
corners at::

  (X[i,   j],   Y[i,   j]),
  (X[i,   j+1], Y[i,   j+1]),
  (X[i+1, j],   Y[i+1, j]),
  (X[i+1, j+1], Y[i+1, j+1]).

Ideally the dimensions of *X* and *Y* should be one greater
than those of *C*; if the dimensions are the same, then the
last row and column of *C* will be ignored.

Note that the the column index corresponds to the
*x*-coordinate, and the row index corresponds to *y*; for
details, see the :ref:`Grid Orientation
<axes-pcolor-grid-orientation>` section below.

If either or both of *X* and *Y* are 1-D arrays or column vectors,
they will be expanded as needed into the appropriate 2-D arrays,
making a rectangular grid.

*X*, *Y* and *C* may be masked arrays.  If either C[i, j], or one
of the vertices surrounding C[i,j] (*X* or *Y* at [i, j], [i+1, j],
[i, j+1],[i+1, j+1]) is masked, nothing is plotted.

Keyword arguments:

  *cmap*: [ None | Colormap ]
    A :class:`matplotlib.cm.Colormap` instance. If *None*, use
    rc settings.

  norm: [ None | Normalize ]
    An :class:`matplotlib.colors.Normalize` instance is used
    to scale luminance data to 0,1. If *None*, defaults to
    :func:`normalize`.

  *vmin*/*vmax*: [ None | scalar ]
    *vmin* and *vmax* are used in conjunction with *norm* to
    normalize luminance data.  If either are *None*, the min
    and max of the color array *C* is used.  If you pass a
    *norm* instance, *vmin* and *vmax* will be ignored.

  *shading*: [ 'flat' | 'faceted' ]
    If 'faceted', a black grid is drawn around each rectangle; if
    'flat', edges are not drawn. Default is 'flat', contrary to
    Matlab(TM).

    This kwarg is deprecated; please use 'edgecolors' instead:
      * shading='flat' -- edgecolors='None'
      * shading='faceted  -- edgecolors='k'

  *edgecolors*: [ None | 'None' | color | color sequence]
    If *None*, the rc setting is used by default.

    If 'None', edges will not be visible.

    An mpl color or sequence of colors will set the edge color

  *alpha*: 0 <= scalar <= 1
    the alpha blending value

Return value is a :class:`matplotlib.collection.Collection`
instance.

.. _axes-pcolor-grid-orientation:

The grid orientation follows the Matlab(TM) convention: an
array *C* with shape (*nrows*, *ncolumns*) is plotted with
the column number as *X* and the row number as *Y*, increasing
up; hence it is plotted the way the array would be printed,
except that the *Y* axis is reversed.  That is, *C* is taken
as *C*(*y*, *x*).

Similarly for :func:`~matplotlib.pyplot.meshgrid`::

  x = np.arange(5)
  y = np.arange(3)
  X, Y = meshgrid(x,y)

is equivalent to:

  X = array([[0, 1, 2, 3, 4],
             [0, 1, 2, 3, 4],
             [0, 1, 2, 3, 4]])

  Y = array([[0, 0, 0, 0, 0],
             [1, 1, 1, 1, 1],
             [2, 2, 2, 2, 2]])

so if you have::

  C = rand( len(x), len(y))

then you need::

  pcolor(X, Y, C.T)

or::

  pcolor(C.T)

Matlab :func:`pcolor` always discards the last row and column
of *C*, but matplotlib displays the last row and column if *X* and
*Y* are not specified, or if *X* and *Y* have one more row and
column than *C*.

kwargs can be used to control the
:class:`~matplotlib.collection.PolyCollection` properties:

%(PolyCollection)s


return cbook.silent_list('<STR_LIT>',<EOL>self.xaxis.get_majorticklabels())<EOL>

Get the xtick labels as a list of Text instances


_process_plot_var_args.defaultColors = clist[:]<EOL>rcParams['<STR_LIT>'] = clist[<NUM_LIT:0>]<EOL>

Change the default cycle of colors that will be used by the plot
command.  This must be called before creating the
:class:`Axes` to which it will apply; it will
apply to all future axes.

*clist* is a sequence of mpl color specifiers


def axhspan(self, ymin, ymax, xmin=<NUM_LIT:0>, xmax=<NUM_LIT:1>, **kwargs):

trans = mtransforms.blended_transform_factory(<EOL>self.transAxes, self.transData)<EOL>self._process_unit_info( [xmin, xmax], [ymin, ymax], kwargs=kwargs )<EOL>xmin, xmax = self.convert_xunits( [xmin, xmax] )<EOL>ymin, ymax = self.convert_yunits( [ymin, ymax] )<EOL>verts = (xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)<EOL>p = mpatches.Polygon(verts, **kwargs)<EOL>p.set_transform(trans)<EOL>p.x_isdata = False<EOL>self.add_patch(p)<EOL>return p<EOL>

call signature::

  axhspan(ymin, ymax, xmin=0, xmax=1, **kwargs)

Axis Horizontal Span.

*y* coords are in data units and *x* coords are in axes (relative
0-1) units.

Draw a horizontal span (rectangle) from *ymin* to *ymax*.
With the default values of *xmin* = 0 and *xmax* = 1, this
always spans the xrange, regardless of the xlim settings, even
if you change them, eg. with the :meth:`set_xlim` command.
That is, the horizontal extent is in axes coords: 0=left,
0.5=middle, 1.0=right but the *y* location is in data
coordinates.

Return value is a :class:`matplotlib.patches.Polygon`
instance.

Examples:

* draw a gray rectangle from *y* = 0.25-0.75 that spans the
  horizontal extent of the axes

    >>> axhspan(0.25, 0.75, facecolor='0.5', alpha=0.5)

Valid kwargs are :class:`~matplotlib.patches.Polygon` properties:

%(Polygon)s

**Example:**

.. plot:: mpl_examples/pylab_examples/axhspan_demo.py


def vlines(self, x, ymin, ymax, colors='<STR_LIT:k>', linestyles='<STR_LIT>',<EOL>label='<STR_LIT>', **kwargs):

if kwargs.get('<STR_LIT>') is not None:<EOL><INDENT>raise DeprecationWarning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>self._process_unit_info(xdata=x, ydata=ymin, kwargs=kwargs)<EOL>x = self.convert_xunits( x )<EOL>ymin = self.convert_yunits( ymin )<EOL>ymax = self.convert_yunits( ymax )<EOL>if not iterable(x): x = [x]<EOL>if not iterable(ymin): ymin = [ymin]<EOL>if not iterable(ymax): ymax = [ymax]<EOL>x = np.asarray(x)<EOL>ymin = np.asarray(ymin)<EOL>ymax = np.asarray(ymax)<EOL>if len(ymin)==<NUM_LIT:1>:<EOL><INDENT>ymin = np.resize( ymin, x.shape )<EOL><DEDENT>if len(ymax)==<NUM_LIT:1>:<EOL><INDENT>ymax = np.resize( ymax, x.shape )<EOL><DEDENT>if len(ymin)!=len(x):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if len(ymax)!=len(x):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>Y = np.array([ymin, ymax]).T<EOL>verts = [ ((thisx, thisymin), (thisx, thisymax))<EOL>for thisx, (thisymin, thisymax) in zip(x,Y)]<EOL>coll = mcoll.LineCollection(verts, colors=colors,<EOL>linestyles=linestyles, label=label)<EOL>self.add_collection(coll)<EOL>coll.update(kwargs)<EOL>minx = min( x )<EOL>maxx = max( x )<EOL>miny = min( min(ymin), min(ymax) )<EOL>maxy = max( max(ymin), max(ymax) )<EOL>corners = (minx, miny), (maxx, maxy)<EOL>self.update_datalim(corners)<EOL>self.autoscale_view()<EOL>return coll<EOL>

call signature::

  vlines(x, ymin, ymax, color='k', linestyles='solid')

Plot vertical lines at each *x* from *ymin* to *ymax*.  *ymin*
or *ymax* can be scalars or len(*x*) numpy arrays.  If they are
scalars, then the respective values are constant, else the
heights of the lines are determined by *ymin* and *ymax*.

*colors*
  a line collections color args, either a single color
  or a len(*x*) list of colors

*linestyles*

  one of [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ]

Returns the :class:`matplotlib.collections.LineCollection`
that was added.

kwargs are :class:`~matplotlib.collections.LineCollection` properties:

%(LineCollection)s


return self._frameon<EOL>

Get whether the axes rectangle patch is drawn


return True<EOL>

Return *True* if this axes support the zoom box


def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs):

return self.yaxis.set_ticklabels(labels, fontdict,<EOL>minor=minor, **kwargs)<EOL>

call signature::

  set_yticklabels(labels, fontdict=None, minor=False, **kwargs)

Set the ytick labels with list of strings *labels*.  Return a list of
:class:`~matplotlib.text.Text` instances.

*kwargs* set :class:`~matplotlib.text.Text` properties for the labels.
Valid properties are
%(Text)s

ACCEPTS: sequence of strings


return mtable.table(self, **kwargs)<EOL>

call signature::

  table(cellText=None, cellColours=None,
        cellLoc='right', colWidths=None,
        rowLabels=None, rowColours=None, rowLoc='left',
        colLabels=None, colColours=None, colLoc='center',
        loc='bottom', bbox=None):

Add a table to the current axes.  Returns a
:class:`matplotlib.table.Table` instance.  For finer grained
control over tables, use the :class:`~matplotlib.table.Table`
class and add it to the axes with
:meth:`~matplotlib.axes.Axes.add_table`.

Thanks to John Gill for providing the class and table.

kwargs control the :class:`~matplotlib.table.Table`
properties:

%(Table)s


if not self._hold: self.cla()<EOL>dx = {'<STR_LIT>': kwargs.pop('<STR_LIT>', <NUM_LIT:10>),<EOL>'<STR_LIT>': kwargs.pop('<STR_LIT>', None),<EOL>}<EOL>dy = {'<STR_LIT>': kwargs.pop('<STR_LIT>', <NUM_LIT:10>),<EOL>'<STR_LIT>': kwargs.pop('<STR_LIT>', None),<EOL>}<EOL>self.set_xscale('<STR_LIT>', **dx)<EOL>self.set_yscale('<STR_LIT>', **dy)<EOL>b =  self._hold<EOL>self._hold = True <EOL>l = self.plot(*args, **kwargs)<EOL>self._hold = b    <EOL>return l<EOL>

call signature::

  loglog(*args, **kwargs)

Make a plot with log scaling on the *x* and *y* axis.

:func:`~matplotlib.pyplot.loglog` supports all the keyword
arguments of :func:`~matplotlib.pyplot.plot` and
:meth:`matplotlib.axes.Axes.set_xscale` /
:meth:`matplotlib.axes.Axes.set_yscale`.

Notable keyword arguments:

  *basex*/*basey*: scalar > 1
    base of the *x*/*y* logarithm

  *subsx*/*subsy*: [ None | sequence ]
    the location of the minor *x*/*y* ticks; *None* defaults
    to autosubs, which depend on the number of decades in the
    plot; see :meth:`matplotlib.axes.Axes.set_xscale` /
    :meth:`matplotlib.axes.Axes.set_yscale` for details

The remaining valid kwargs are
:class:`~matplotlib.lines.Line2D` properties:

%(Line2D)s

**Example:**

.. plot:: mpl_examples/pylab_examples/log_demo.py


def axhline(self, y=<NUM_LIT:0>, xmin=<NUM_LIT:0>, xmax=<NUM_LIT:1>, **kwargs):

ymin, ymax = self.get_ybound()<EOL>yy = self.convert_yunits( y )<EOL>scaley = (yy<ymin) or (yy>ymax)<EOL>trans = mtransforms.blended_transform_factory(<EOL>self.transAxes, self.transData)<EOL>l = mlines.Line2D([xmin,xmax], [y,y], transform=trans, **kwargs)<EOL>l.x_isdata = False<EOL>self.add_line(l)<EOL>self.autoscale_view(scalex=False, scaley=scaley)<EOL>return l<EOL>

call signature::

  axhline(y=0, xmin=0, xmax=1, **kwargs)

Axis Horizontal Line

Draw a horizontal line at *y* from *xmin* to *xmax*.  With the
default values of *xmin* = 0 and *xmax* = 1, this line will
always span the horizontal extent of the axes, regardless of
the xlim settings, even if you change them, eg. with the
:meth:`set_xlim` command.  That is, the horizontal extent is
in axes coords: 0=left, 0.5=middle, 1.0=right but the *y*
location is in data coordinates.

Return value is the :class:`~matplotlib.lines.Line2D`
instance.  kwargs are the same as kwargs to plot, and can be
used to control the line properties.  Eg.,

* draw a thick red hline at *y* = 0 that spans the xrange

    >>> axhline(linewidth=4, color='r')

* draw a default hline at *y* = 1 that spans the xrange

    >>> axhline(y=1)

* draw a default hline at *y* = .5 that spans the the middle half of
  the xrange

    >>> axhline(y=.5, xmin=0.25, xmax=0.75)

Valid kwargs are :class:`~matplotlib.lines.Line2D` properties:

%(Line2D)s

.. seealso::
    :meth:`axhspan`:
        for example plot and source code


if len(args)==<NUM_LIT:1>:<EOL><INDENT>lw, c = args[<NUM_LIT:0>]<EOL><DEDENT>elif len(args)==<NUM_LIT:2>:<EOL><INDENT>lw, c = args<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>c =mcolors.colorConverter.to_rgba(c)<EOL>self._cursorProps = lw, c<EOL>

Set the cursor property as::

  ax.set_cursor_props(linewidth, color)

or::

  ax.set_cursor_props((linewidth, color))

ACCEPTS: a (*float*, *color*) tuple


if not self._hold: self.cla()<EOL>d = {'<STR_LIT>': kwargs.pop('<STR_LIT>', <NUM_LIT:10>),<EOL>'<STR_LIT>': kwargs.pop('<STR_LIT>', None),<EOL>}<EOL>self.set_yscale('<STR_LIT>', **d)<EOL>b =  self._hold<EOL>self._hold = True <EOL>l = self.plot(*args, **kwargs)<EOL>self._hold = b    <EOL>return l<EOL>

call signature::

  semilogy(*args, **kwargs)

Make a plot with log scaling on the *y* axis.

:func:`semilogy` supports all the keyword arguments of
:func:`~matplotlib.pylab.plot` and
:meth:`matplotlib.axes.Axes.set_yscale`.

Notable keyword arguments:

  *basey*: scalar > 1
    Base of the *y* logarithm

  *subsy*: [ None | sequence ]
    The location of the minor yticks; *None* defaults to
    autosubs, which depend on the number of decades in the
    plot; see :meth:`~matplotlib.axes.Axes.set_yscale` for
    details.

The remaining valid kwargs are
:class:`~matplotlib.lines.Line2D` properties:

%(Line2D)s

.. seealso::
    :meth:`loglog`:
        For example code and figure


self._axisbg = color<EOL>self.patch.set_facecolor(color)<EOL>

set the axes background color

ACCEPTS: any matplotlib color - see
:func:`~matplotlib.pyplot.colors`


def set_xlim(self, xmin=None, xmax=None, emit=True, **kwargs):

if xmax is None and iterable(xmin):<EOL><INDENT>xmin,xmax = xmin<EOL><DEDENT>self._process_unit_info(xdata=(xmin, xmax))<EOL>if xmin is not None:<EOL><INDENT>xmin = self.convert_xunits(xmin)<EOL><DEDENT>if xmax is not None:<EOL><INDENT>xmax = self.convert_xunits(xmax)<EOL><DEDENT>old_xmin,old_xmax = self.get_xlim()<EOL>if xmin is None: xmin = old_xmin<EOL>if xmax is None: xmax = old_xmax<EOL>xmin, xmax = mtransforms.nonsingular(xmin, xmax, increasing=False)<EOL>xmin, xmax = self.xaxis.limit_range_for_scale(xmin, xmax)<EOL>self.viewLim.intervalx = (xmin, xmax)<EOL>if emit:<EOL><INDENT>self.callbacks.process('<STR_LIT>', self)<EOL>for other in self._shared_x_axes.get_siblings(self):<EOL><INDENT>if other is not self:<EOL><INDENT>other.set_xlim(self.viewLim.intervalx, emit=False)<EOL>if (other.figure != self.figure and<EOL>other.figure.canvas is not None):<EOL><INDENT>other.figure.canvas.draw_idle()<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return xmin, xmax<EOL>

call signature::

  set_xlim(self, *args, **kwargs)

Set the limits for the xaxis

Returns the current xlimits as a length 2 tuple: [*xmin*, *xmax*]

Examples::

  set_xlim((valmin, valmax))
  set_xlim(valmin, valmax)
  set_xlim(xmin=1) # xmax unchanged
  set_xlim(xmax=1) # xmin unchanged

Keyword arguments:

  *ymin*: scalar
    the min of the ylim
  *ymax*: scalar
    the max of the ylim
  *emit*: [ True | False ]
    notify observers of lim change

ACCEPTS: len(2) sequence of floats


return (self._xaxis_transform +<EOL>mtransforms.ScaledTranslation(<NUM_LIT:0>, pad_points / <NUM_LIT>,<EOL>self.figure.dpi_scale_trans),<EOL>"<STR_LIT>", "<STR_LIT>")<EOL>

Get the transformation used for drawing the secondary x-axis
labels, which will add the given amount of padding (in points)
between the axes and the label.  The x-direction is in data
coordinates and the y-direction is in axis coordinates.
Returns a 3-tuple of the form::

  (transform, valign, halign)

where *valign* and *halign* are requested alignments for the
text.

.. note::
    This transformation is primarily used by the
    :class:`~matplotlib.axis.Axis` class, and is meant to be
    overridden by new kinds of projections that may need to
    place axis elements in different locations.


def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs):

return self.xaxis.set_ticklabels(labels, fontdict,<EOL>minor=minor, **kwargs)<EOL>

call signature::

  set_xticklabels(labels, fontdict=None, minor=False, **kwargs)

Set the xtick labels with list of strings *labels*. Return a
list of axis text instances.

*kwargs* set the :class:`~matplotlib.text.Text` properties.
Valid properties are
%(Text)s

ACCEPTS: sequence of strings


linestyle = None<EOL>marker = None<EOL>color = None<EOL>try:<EOL><INDENT>color = mcolors.colorConverter.to_rgb(fmt)<EOL>return linestyle, marker, color     <EOL><DEDENT>except ValueError:<EOL><INDENT>pass                                <EOL><DEDENT>if fmt.find('<STR_LIT>')>=<NUM_LIT:0>:<EOL><INDENT>linestyle = '<STR_LIT>'<EOL>fmt = fmt.replace('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>if fmt.find('<STR_LIT>')>=<NUM_LIT:0>:<EOL><INDENT>linestyle = '<STR_LIT>'<EOL>fmt = fmt.replace('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>if fmt.find('<STR_LIT:U+0020>')>=<NUM_LIT:0>:<EOL><INDENT>linestyle = '<STR_LIT:None>'<EOL>fmt = fmt.replace('<STR_LIT:U+0020>', '<STR_LIT>')<EOL><DEDENT>chars = [c for c in fmt]<EOL>for c in chars:<EOL><INDENT>if c in mlines.lineStyles:<EOL><INDENT>if linestyle is not None:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % fmt)<EOL><DEDENT>linestyle = c<EOL><DEDENT>elif c in mlines.lineMarkers:<EOL><INDENT>if marker is not None:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % fmt)<EOL><DEDENT>marker = c<EOL><DEDENT>elif c in mcolors.colorConverter.colors:<EOL><INDENT>if color is not None:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % fmt)<EOL><DEDENT>color = c<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % c)<EOL><DEDENT><DEDENT>if linestyle is None and marker is None:<EOL><INDENT>linestyle = rcParams['<STR_LIT>']<EOL><DEDENT>if linestyle is None:<EOL><INDENT>linestyle = '<STR_LIT:None>'<EOL><DEDENT>if marker is None:<EOL><INDENT>marker = '<STR_LIT:None>'<EOL><DEDENT>return linestyle, marker, color<EOL>

Process a matlab(TM) style color/line style format string.  Return a
(*linestyle*, *color*) tuple as a result of the processing.  Default
values are ('-', 'b').  Example format strings include:

* 'ko': black circles
* '.b': blue dots
* 'r--': red dashed lines

.. seealso::
    :func:`~matplotlib.Line2D.lineStyles` and
    :func:`~matplotlib.pyplot.colors`:
        for all possible styles and color format string.


return self._shared_y_axes<EOL>

Return a copy of the shared axes Grouper object for y axes


def set_aspect(self, aspect, adjustable=None, anchor=None):

if aspect in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>self._aspect = '<STR_LIT>'<EOL><DEDENT>elif aspect == '<STR_LIT>':<EOL><INDENT>self._aspect = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>self._aspect = float(aspect) <EOL><DEDENT>if adjustable is not None:<EOL><INDENT>self.set_adjustable(adjustable)<EOL><DEDENT>if anchor is not None:<EOL><INDENT>self.set_anchor(anchor)<EOL><DEDENT>


def set_position(self, pos, which='<STR_LIT>'):

if not isinstance(pos, mtransforms.BboxBase):<EOL><INDENT>pos = mtransforms.Bbox.from_bounds(*pos)<EOL><DEDENT>if which in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>self._position.set(pos)<EOL><DEDENT>if which in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>self._originalPosition.set(pos)<EOL><DEDENT>

Set the axes position with::

  pos = [left, bottom, width, height]

in relative 0,1 coords, or *pos* can be a
:class:`~matplotlib.transforms.Bbox`

There are two position variables: one which is ultimately
used, but which may be modified by :meth:`apply_aspect`, and a
second which is the starting point for :meth:`apply_aspect`.

Optional keyword arguments:
  *which*

    ==========   ====================
    value        description
    ==========   ====================
    'active'     to change the first
    'original'   to change the second
    'both'       to change both
    ==========   ====================


self._get_lines.set_color_cycle(clist)<EOL>

Set the color cycle for any future plot commands on this Axes.

clist is a list of mpl color specifiers.


if not self._hold: self.cla()<EOL>patches = []<EOL>for poly in self._get_patches_for_fill(*args, **kwargs):<EOL><INDENT>self.add_patch( poly )<EOL>patches.append( poly )<EOL><DEDENT>self.autoscale_view()<EOL>return patches<EOL>

call signature::

  fill(*args, **kwargs)

Plot filled polygons.  *args* is a variable length argument,
allowing for multiple *x*, *y* pairs with an optional color
format string; see :func:`~matplotlib.pyplot.plot` for details
on the argument parsing.  For example, to plot a polygon with
vertices at *x*, *y* in blue.::

  ax.fill(x,y, 'b' )

An arbitrary number of *x*, *y*, *color* groups can be specified::

  ax.fill(x1, y1, 'g', x2, y2, 'r')

Return value is a list of :class:`~matplotlib.patches.Patch`
instances that were added.

The same color strings that :func:`~matplotlib.pyplot.plot`
supports are supported by the fill format string.

If you would like to fill below a curve, eg. shade a region
between 0 and *y* along *x*, use :meth:`fill_between`

The *closed* kwarg will close the polygon when *True* (default).

kwargs control the Polygon properties:

%(Polygon)s

**Example:**

.. plot:: mpl_examples/pylab_examples/fill_demo.py


self._set_artist_props(line)<EOL>line.set_clip_path(self.patch)<EOL>self._update_line_limits(line)<EOL>if not line.get_label():<EOL><INDENT>line.set_label('<STR_LIT>'%len(self.lines))<EOL><DEDENT>self.lines.append(line)<EOL>line._remove_method = lambda h: self.lines.remove(h)<EOL>

Add a :class:`~matplotlib.lines.Line2D` to the list of plot
lines


def set_ylim(self, ymin=None, ymax=None, emit=True, **kwargs):

if ymax is None and iterable(ymin):<EOL><INDENT>ymin,ymax = ymin<EOL><DEDENT>if ymin is not None:<EOL><INDENT>ymin = self.convert_yunits(ymin)<EOL><DEDENT>if ymax is not None:<EOL><INDENT>ymax = self.convert_yunits(ymax)<EOL><DEDENT>old_ymin,old_ymax = self.get_ylim()<EOL>if ymin is None: ymin = old_ymin<EOL>if ymax is None: ymax = old_ymax<EOL>ymin, ymax = mtransforms.nonsingular(ymin, ymax, increasing=False)<EOL>ymin, ymax = self.yaxis.limit_range_for_scale(ymin, ymax)<EOL>self.viewLim.intervaly = (ymin, ymax)<EOL>if emit:<EOL><INDENT>self.callbacks.process('<STR_LIT>', self)<EOL>for other in self._shared_y_axes.get_siblings(self):<EOL><INDENT>if other is not self:<EOL><INDENT>other.set_ylim(self.viewLim.intervaly, emit=False)<EOL>if (other.figure != self.figure and<EOL>other.figure.canvas is not None):<EOL><INDENT>other.figure.canvas.draw_idle()<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return ymin, ymax<EOL>

call signature::

  set_ylim(self, *args, **kwargs):

Set the limits for the yaxis; v = [ymin, ymax]::

  set_ylim((valmin, valmax))
  set_ylim(valmin, valmax)
  set_ylim(ymin=1) # ymax unchanged
  set_ylim(ymax=1) # ymin unchanged

Keyword arguments:

  *ymin*: scalar
    the min of the ylim
  *ymax*: scalar
    the max of the ylim
  *emit*: [ True | False ]
    notify observers of lim change

Returns the current ylimits as a length 2 tuple

ACCEPTS: len(2) sequence of floats


ax2 = self.figure.add_axes(self.get_position(True), sharex=self,<EOL>frameon=False)<EOL>ax2.yaxis.tick_right()<EOL>ax2.yaxis.set_label_position('<STR_LIT:right>')<EOL>self.yaxis.tick_left()<EOL>return ax2<EOL>

call signature::

  ax = twinx()

create a twin of Axes for generating a plot with a sharex
x-axis but independent y axis.  The y-axis of self will have
ticks on left and the returned axes will have ticks on the
right


def set_ybound(self, lower=None, upper=None):

if upper is None and iterable(lower):<EOL><INDENT>lower,upper = lower<EOL><DEDENT>old_lower,old_upper = self.get_ybound()<EOL>if lower is None: lower = old_lower<EOL>if upper is None: upper = old_upper<EOL>if self.yaxis_inverted():<EOL><INDENT>if lower < upper:<EOL><INDENT>self.set_ylim(upper, lower)<EOL><DEDENT>else:<EOL><INDENT>self.set_ylim(lower, upper)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if lower < upper:<EOL><INDENT>self.set_ylim(lower, upper)<EOL><DEDENT>else:<EOL><INDENT>self.set_ylim(upper, lower)<EOL><DEDENT><DEDENT>

Set the lower and upper numerical bounds of the y-axis.
           This method will honor axes inversion regardless of parameter order.


def set_xbound(self, lower=None, upper=None):

if upper is None and iterable(lower):<EOL><INDENT>lower,upper = lower<EOL><DEDENT>old_lower,old_upper = self.get_xbound()<EOL>if lower is None: lower = old_lower<EOL>if upper is None: upper = old_upper<EOL>if self.xaxis_inverted():<EOL><INDENT>if lower < upper:<EOL><INDENT>self.set_xlim(upper, lower)<EOL><DEDENT>else:<EOL><INDENT>self.set_xlim(lower, upper)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if lower < upper:<EOL><INDENT>self.set_xlim(lower, upper)<EOL><DEDENT>else:<EOL><INDENT>self.set_xlim(upper, lower)<EOL><DEDENT><DEDENT>

Set the lower and upper numerical bounds of the x-axis.
This method will honor axes inversion regardless of parameter order.


def stem(self, x, y, linefmt='<STR_LIT>', markerfmt='<STR_LIT>', basefmt='<STR_LIT>'):

remember_hold=self._hold<EOL>if not self._hold: self.cla()<EOL>self.hold(True)<EOL>markerline, = self.plot(x, y, markerfmt)<EOL>stemlines = []<EOL>for thisx, thisy in zip(x, y):<EOL><INDENT>l, = self.plot([thisx,thisx], [<NUM_LIT:0>, thisy], linefmt)<EOL>stemlines.append(l)<EOL><DEDENT>baseline, = self.plot([np.amin(x), np.amax(x)], [<NUM_LIT:0>,<NUM_LIT:0>], basefmt)<EOL>self.hold(remember_hold)<EOL>return markerline, stemlines, baseline<EOL>

call signature::

  stem(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')

A stem plot plots vertical lines (using *linefmt*) at each *x*
location from the baseline to *y*, and places a marker there
using *markerfmt*.  A horizontal line at 0 is is plotted using
*basefmt*.

Return value is a tuple (*markerline*, *stemlines*,
*baseline*).

.. seealso::
    `this document`__ for details

    :file:`examples/pylab_examples/stem_plot.py`:
        for a demo

__ http://www.mathworks.com/access/helpdesk/help/techdoc/ref/stem.html


return self._navigate<EOL>

Get whether the axes responds to navigation commands


return cbook.silent_list('<STR_LIT>', self.yaxis.get_ticklines())<EOL>

Get the ytick lines as a list of Line2D instances


def change_geometry(self, numrows, numcols, num):

self._rows = numrows<EOL>self._cols = numcols<EOL>self._num = num-<NUM_LIT:1><EOL>self.update_params()<EOL>self.set_position(self.figbox)<EOL>

change subplot geometry, eg. from 1,1,1 to 2,2,3


def set_ylabel(self, ylabel, fontdict=None, **kwargs):

label = self.yaxis.get_label()<EOL>label.set_text(ylabel)<EOL>if fontdict is not None: label.update(fontdict)<EOL>label.update(kwargs)<EOL>return label<EOL>

call signature::

  set_ylabel(ylabel, fontdict=None, **kwargs)

Set the label for the yaxis

Valid kwargs are Text properties:
%(Text)s
ACCEPTS: str

.. seealso::
    :meth:`text`:
        for information on how override and the optional args work


self._pan_start = cbook.Bunch(<EOL>lim           = self.viewLim.frozen(),<EOL>trans         = self.transData.frozen(),<EOL>trans_inverse = self.transData.inverted().frozen(),<EOL>bbox          = self.bbox.frozen(),<EOL>x             = x,<EOL>y             = y<EOL>)<EOL>

Called when a pan operation has started.

*x*, *y* are the mouse coordinates in display coords.
button is the mouse button number:

* 1: LEFT
* 2: MIDDLE
* 3: RIGHT

.. note::
    Intended to be overridden by new projection types.


def hlines(self, y, xmin, xmax, colors='<STR_LIT:k>', linestyles='<STR_LIT>',<EOL>label='<STR_LIT>', **kwargs):

if kwargs.get('<STR_LIT>') is not None:<EOL><INDENT>raise DeprecationWarning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>y = self.convert_yunits( y )<EOL>xmin = self.convert_xunits( xmin )<EOL>xmax = self.convert_xunits( xmax )<EOL>if not iterable(y): y = [y]<EOL>if not iterable(xmin): xmin = [xmin]<EOL>if not iterable(xmax): xmax = [xmax]<EOL>y = np.asarray(y)<EOL>xmin = np.asarray(xmin)<EOL>xmax = np.asarray(xmax)<EOL>if len(xmin)==<NUM_LIT:1>:<EOL><INDENT>xmin = np.resize( xmin, y.shape )<EOL><DEDENT>if len(xmax)==<NUM_LIT:1>:<EOL><INDENT>xmax = np.resize( xmax, y.shape )<EOL><DEDENT>if len(xmin)!=len(y):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if len(xmax)!=len(y):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>verts = [ ((thisxmin, thisy), (thisxmax, thisy))<EOL>for thisxmin, thisxmax, thisy in zip(xmin, xmax, y)]<EOL>coll = mcoll.LineCollection(verts, colors=colors,<EOL>linestyles=linestyles, label=label)<EOL>self.add_collection(coll)<EOL>coll.update(kwargs)<EOL>minx = min(xmin.min(), xmax.min())<EOL>maxx = max(xmin.max(), xmax.max())<EOL>miny = y.min()<EOL>maxy = y.max()<EOL>corners = (minx, miny), (maxx, maxy)<EOL>self.update_datalim(corners)<EOL>self.autoscale_view()<EOL>return coll<EOL>

call signature::

  hlines(y, xmin, xmax, colors='k', linestyles='solid', **kwargs)

Plot horizontal lines at each *y* from *xmin* to *xmax*.

Returns the :class:`~matplotlib.collections.LineCollection`
that was added.

Required arguments:

  *y*:
    a 1-D numpy array or iterable.

  *xmin* and *xmax*:
    can be scalars or ``len(x)`` numpy arrays.  If they are
    scalars, then the respective values are constant, else the
    widths of the lines are determined by *xmin* and *xmax*.

Optional keyword arguments:

  *colors*:
    a line collections color argument, either a single color
    or a ``len(y)`` list of colors

  *linestyles*:
    [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ]

**Example:**

.. plot:: mpl_examples/pylab_examples/hline_demo.py


assert self._cachedRenderer is not None<EOL>a.draw(self._cachedRenderer)<EOL>

This method can only be used after an initial draw which
caches the renderer.  It is used to efficiently update Axes
data (axis ticks, labels, etc are not updated)


return cbook.silent_list('<STR_LIT>',<EOL>self.xaxis.get_ticklabels(minor=minor))<EOL>

Get the xtick labels as a list of Text instances


def _process_unit_info(self, xdata=None, ydata=None, kwargs=None):

if self.xaxis is None or self.yaxis is None: return<EOL>if xdata is not None:<EOL><INDENT>if not self.xaxis.have_units():<EOL><INDENT>self.xaxis.update_units(xdata)<EOL><DEDENT><DEDENT>if ydata is not None:<EOL><INDENT>if not self.yaxis.have_units():<EOL><INDENT>self.yaxis.update_units(ydata)<EOL><DEDENT><DEDENT>if kwargs is not None:<EOL><INDENT>xunits = kwargs.pop( '<STR_LIT>', self.xaxis.units)<EOL>if xunits!=self.xaxis.units:<EOL><INDENT>self.xaxis.set_units(xunits)<EOL>if xdata is not None:<EOL><INDENT>self.xaxis.update_units(xdata)<EOL><DEDENT><DEDENT>yunits = kwargs.pop('<STR_LIT>', self.yaxis.units)<EOL>if yunits!=self.yaxis.units:<EOL><INDENT>self.yaxis.set_units(yunits)<EOL>if ydata is not None:<EOL><INDENT>self.yaxis.update_units(ydata)<EOL><DEDENT><DEDENT><DEDENT>

look for unit *kwargs* and update the axis instances as necessary


return self._hold<EOL>


def __pick(self, x, y, trans=None, among=None):

<EOL>if trans is not None:<EOL><INDENT>xywin = trans.transform_point((x,y))<EOL><DEDENT>else:<EOL><INDENT>xywin = x,y<EOL><DEDENT>def dist_points(p1, p2):<EOL><INDENT>'<STR_LIT>'<EOL>x1, y1 = p1<EOL>x2, y2 = p2<EOL>return math.sqrt((x1-x2)**<NUM_LIT:2>+(y1-y2)**<NUM_LIT:2>)<EOL><DEDENT>def dist_x_y(p1, x, y):<EOL><INDENT>'<STR_LIT>'<EOL>x1, y1 = p1<EOL>return min(np.sqrt((x-x1)**<NUM_LIT:2>+(y-y1)**<NUM_LIT:2>))<EOL><DEDENT>def dist(a):<EOL><INDENT>if isinstance(a, Text):<EOL><INDENT>bbox = a.get_window_extent()<EOL>l,b,w,h = bbox.bounds<EOL>verts = (l,b), (l,b+h), (l+w,b+h), (l+w, b)<EOL>xt, yt = list(zip(*verts))<EOL><DEDENT>elif isinstance(a, Patch):<EOL><INDENT>path = a.get_path()<EOL>tverts = a.get_transform().transform_path(path)<EOL>xt, yt = list(zip(*tverts))<EOL><DEDENT>elif isinstance(a, mlines.Line2D):<EOL><INDENT>xdata = a.get_xdata(orig=False)<EOL>ydata = a.get_ydata(orig=False)<EOL>xt, yt = a.get_transform().numerix_x_y(xdata, ydata)<EOL><DEDENT>return dist_x_y(xywin, np.asarray(xt), np.asarray(yt))<EOL><DEDENT>artists = self.lines + self.patches + self.texts<EOL>if callable(among):<EOL><INDENT>artists = list(filter(test, artists))<EOL><DEDENT>elif iterable(among):<EOL><INDENT>amongd = dict([(k,<NUM_LIT:1>) for k in among])<EOL>artists = [a for a in artists if a in amongd]<EOL><DEDENT>elif among is None:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if not len(artists): return None<EOL>ds = [ (dist(a),a) for a in artists]<EOL>ds.sort()<EOL>return ds[<NUM_LIT:0>][<NUM_LIT:1>]<EOL>

Return the artist under point that is closest to the *x*, *y*.
If *trans* is *None*, *x*, and *y* are in window coords,
(0,0 = lower left).  Otherwise, *trans* is a
:class:`~matplotlib.transforms.Transform` that specifies the
coordinate system of *x*, *y*.

The selection of artists from amongst which the pick function
finds an artist can be narrowed using the optional keyword
argument *among*. If provided, this should be either a sequence
of permitted artists or a function taking an artist as its
argument and returning a true value if and only if that artist
can be selected.

Note this algorithm calculates distance to the vertices of the
polygon, so if you want to pick a patch, click on the edge!


self.xaxis.set_scale(value, **kwargs)<EOL>self.autoscale_view()<EOL>self._update_transScale()<EOL>

call signature::

  set_xscale(value)

Set the scaling of the x-axis: %(scale)s

ACCEPTS: [%(scale)s]

Different kwargs are accepted, depending on the scale:
%(scale_docs)s


if anchor in list(mtransforms.Bbox.coefs.keys()) or len(anchor) == <NUM_LIT:2>:<EOL><INDENT>self._anchor = anchor<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' %<EOL>'<STR_LIT:U+002CU+0020>'.join(list(mtransforms.BBox.coefs.keys())))<EOL><DEDENT>

*anchor*

  =====  ============
  value  description
  =====  ============
  'C'    Center
  'SW'   bottom left
  'S'    bottom
  'SE'   bottom right
  'E'    right
  'NE'   top right
  'N'    top
  'NW'   top left
  'W'    left
  =====  ============


return cbook.silent_list('<STR_LIT>', self.images)<EOL>

return a list of Axes images contained by the Axes


left, right = self.get_ylim()<EOL>if left < right:<EOL><INDENT>return left, right<EOL><DEDENT>else:<EOL><INDENT>return right, left<EOL><DEDENT>

Return y-axis numerical bounds in the form of lowerBound < upperBound


if adjustable in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if self in self._shared_x_axes or self in self._shared_y_axes:<EOL><INDENT>if adjustable == '<STR_LIT>':<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>self._adjustable = adjustable<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>


where = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>if where not in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>kwargs['<STR_LIT>'] = '<STR_LIT>' + where<EOL>return self.plot(x, y, *args, **kwargs)<EOL>

call signature::

  step(x, y, *args, **kwargs)

Make a step plot. Additional keyword args to :func:`step` are the same
as those for :func:`~matplotlib.pyplot.plot`.

*x* and *y* must be 1-D sequences, and it is assumed, but not checked,
that *x* is uniformly increasing.

Keyword arguments:

*where*: [ 'pre' | 'post' | 'mid'  ]
  If 'pre', the interval from x[i] to x[i+1] has level y[i]

  If 'post', that interval has level y[i+1]

  If 'mid', the jumps in *y* occur half-way between the
  *x*-values.


Z = np.asarray(Z)<EOL>nr, nc = Z.shape<EOL>extent = [-<NUM_LIT:0.5>, nc-<NUM_LIT:0.5>, nr-<NUM_LIT:0.5>, -<NUM_LIT:0.5>]<EOL>kw = {'<STR_LIT>': extent,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'}          <EOL>kw.update(kwargs)<EOL>im = self.imshow(Z, **kw)<EOL>self.title.set_y(<NUM_LIT>)<EOL>self.xaxis.tick_top()<EOL>self.xaxis.set_ticks_position('<STR_LIT>')<EOL>self.xaxis.set_major_locator(mticker.MaxNLocator(nbins=<NUM_LIT:9>,<EOL>steps=[<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:5>, <NUM_LIT:10>],<EOL>integer=True))<EOL>self.yaxis.set_major_locator(mticker.MaxNLocator(nbins=<NUM_LIT:9>,<EOL>steps=[<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:5>, <NUM_LIT:10>],<EOL>integer=True))<EOL>return im<EOL>

Plot a matrix or array as an image.

The matrix will be shown the way it would be printed,
with the first row at the top.  Row and column numbering
is zero-based.

Argument:
    *Z*   anything that can be interpreted as a 2-D array

kwargs all are passed to :meth:`~matplotlib.axes.Axes.imshow`.
:meth:`matshow` sets defaults for *extent*, *origin*,
*interpolation*, and *aspect*; use care in overriding the
*extent* and *origin* kwargs, because they interact.  (Also,
if you want to change them, you probably should be using
imshow directly in your own version of matshow.)

Returns: an :class:`matplotlib.image.AxesImage` instance.


warnings.warn('<STR_LIT>', DeprecationWarning)<EOL>return self.patch<EOL>


return self._rows, self._cols, self._num+<NUM_LIT:1><EOL>


def cohere(self, x, y, NFFT=<NUM_LIT>, Fs=<NUM_LIT:2>, Fc=<NUM_LIT:0>, detrend=mlab.detrend_none,<EOL>window=mlab.window_hanning, noverlap=<NUM_LIT:0>, pad_to=None,<EOL>sides='<STR_LIT:default>', scale_by_freq=None, **kwargs):

if not self._hold: self.cla()<EOL>cxy, freqs = mlab.cohere(x, y, NFFT, Fs, detrend, window, noverlap,<EOL>scale_by_freq)<EOL>freqs += Fc<EOL>self.plot(freqs, cxy, **kwargs)<EOL>self.set_xlabel('<STR_LIT>')<EOL>self.set_ylabel('<STR_LIT>')<EOL>self.grid(True)<EOL>return cxy, freqs<EOL>

call signature::

  cohere(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none,
         window = mlab.window_hanning, noverlap=0, pad_to=None,
         sides='default', scale_by_freq=None, **kwargs)

cohere the coherence between *x* and *y*.  Coherence is the normalized
cross spectral density:

.. math::

  C_{xy} = \\frac{|P_{xy}|^2}{P_{xx}P_{yy}}

%(PSD)s

  *Fc*: integer
    The center frequency of *x* (defaults to 0), which offsets
    the x extents of the plot to reflect the frequency range used
    when a signal is acquired and then filtered and downsampled to
    baseband.

The return value is a tuple (*Cxy*, *f*), where *f* are the
frequencies of the coherence vector.

kwargs are applied to the lines.

References:

  * Bendat & Piersol -- Random Data: Analysis and Measurement
    Procedures, John Wiley & Sons (1986)

kwargs control the :class:`~matplotlib.lines.Line2D`
properties of the coherence plot:

%(Line2D)s

**Example:**

.. plot:: mpl_examples/pylab_examples/cohere_demo.py


<EOL>if (isinstance(patch, mpatches.Rectangle) and<EOL>(patch.get_width()==<NUM_LIT:0> or patch.get_height()==<NUM_LIT:0>)):<EOL><INDENT>return<EOL><DEDENT>vertices = patch.get_path().vertices<EOL>if vertices.size > <NUM_LIT:0>:<EOL><INDENT>xys = patch.get_patch_transform().transform(vertices)<EOL>if patch.get_data_transform() != self.transData:<EOL><INDENT>transform = (patch.get_data_transform() +<EOL>self.transData.inverted())<EOL>xys = transform.transform(xys)<EOL><DEDENT>self.update_datalim(xys, updatex=patch.x_isdata,<EOL>updatey=patch.y_isdata)<EOL><DEDENT>


rows = self._rows<EOL>cols = self._cols<EOL>num = self._num<EOL>pars = self.figure.subplotpars<EOL>left = pars.left<EOL>right = pars.right<EOL>bottom = pars.bottom<EOL>top = pars.top<EOL>wspace = pars.wspace<EOL>hspace = pars.hspace<EOL>totWidth = right-left<EOL>totHeight = top-bottom<EOL>figH = totHeight/(rows + hspace*(rows-<NUM_LIT:1>))<EOL>sepH = hspace*figH<EOL>figW = totWidth/(cols + wspace*(cols-<NUM_LIT:1>))<EOL>sepW = wspace*figW<EOL>rowNum, colNum =  divmod(num, cols)<EOL>figBottom = top - (rowNum+<NUM_LIT:1>)*figH - rowNum*sepH<EOL>figLeft = left + colNum*(figW + sepW)<EOL>self.figbox = mtransforms.Bbox.from_bounds(figLeft, figBottom,<EOL>figW, figH)<EOL>self.rowNum = rowNum<EOL>self.colNum = colNum<EOL>self.numRows = rows<EOL>self.numCols = cols<EOL>if <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>', rows, cols, num)<EOL>print('<STR_LIT>', left, bottom, right, top)<EOL>print('<STR_LIT>', self.figBottom)<EOL>print('<STR_LIT>', self.figLeft)<EOL>print('<STR_LIT>', self.figW)<EOL>print('<STR_LIT>', self.figH)<EOL>print('<STR_LIT>', self.rowNum)<EOL>print('<STR_LIT>', self.colNum)<EOL>print('<STR_LIT>', self.numRows)<EOL>print('<STR_LIT>', self.numCols)<EOL><DEDENT>

update the subplot position from fig.subplotpars


return self.patch.contains(mouseevent)[<NUM_LIT:0>]<EOL>

return *True* if the given *mouseevent* (in display coords)
is in the Axes


return cbook.silent_list('<STR_LIT>', self.xaxis.get_gridlines())<EOL>

Get the x grid lines as a list of Line2D instances


left, right = self.get_xlim()<EOL>if left < right:<EOL><INDENT>return left, right<EOL><DEDENT>else:<EOL><INDENT>return right, left<EOL><DEDENT>

Returns the x-axis numerical bounds where::

  lowerBound < upperBound


return self._axisbg<EOL>


label = self.xaxis.get_label()<EOL>return label.get_text()<EOL>


def imshow(self, X, cmap=None, norm=None, aspect=None,<EOL>interpolation=None, alpha=<NUM_LIT:1.0>, vmin=None, vmax=None,<EOL>origin=None, extent=None, shape=None, filternorm=<NUM_LIT:1>,<EOL>filterrad=<NUM_LIT>, imlim=None, resample=None, url=None, **kwargs):

if not self._hold: self.cla()<EOL>if norm is not None: assert(isinstance(norm, mcolors.Normalize))<EOL>if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))<EOL>if aspect is None: aspect = rcParams['<STR_LIT>']<EOL>self.set_aspect(aspect)<EOL>im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent,<EOL>filternorm=filternorm,<EOL>filterrad=filterrad, resample=resample, **kwargs)<EOL>im.set_data(X)<EOL>im.set_alpha(alpha)<EOL>self._set_artist_props(im)<EOL>im.set_clip_path(self.patch)<EOL>if vmin is not None or vmax is not None:<EOL><INDENT>im.set_clim(vmin, vmax)<EOL><DEDENT>else:<EOL><INDENT>im.autoscale_None()<EOL><DEDENT>im.set_url(url)<EOL>xmin, xmax, ymin, ymax = im.get_extent()<EOL>corners = (xmin, ymin), (xmax, ymax)<EOL>self.update_datalim(corners)<EOL>if self._autoscaleon:<EOL><INDENT>self.set_xlim((xmin, xmax))<EOL>self.set_ylim((ymin, ymax))<EOL><DEDENT>self.images.append(im)<EOL>return im<EOL>

call signature::

  imshow(X, cmap=None, norm=None, aspect=None, interpolation=None,
         alpha=1.0, vmin=None, vmax=None, origin=None, extent=None,
         **kwargs)

Display the image in *X* to current axes.  *X* may be a float
array, a uint8 array or a PIL image. If *X* is an array, *X*
can have the following shapes:

* MxN -- luminance (grayscale, float array only)
* MxNx3 -- RGB (float or uint8 array)
* MxNx4 -- RGBA (float or uint8 array)

The value for each component of MxNx3 and MxNx4 float arrays should be
in the range 0.0 to 1.0; MxN float arrays may be normalised.

An :class:`matplotlib.image.AxesImage` instance is returned.

Keyword arguments:

  *cmap*: [ None | Colormap ]
    A :class:`matplotlib.cm.Colormap` instance, eg. cm.jet.
    If *None*, default to rc ``image.cmap`` value.

    *cmap* is ignored when *X* has RGB(A) information

  *aspect*: [ None | 'auto' | 'equal' | scalar ]
    If 'auto', changes the image aspect ratio to match that of the axes

    If 'equal', and *extent* is *None*, changes the axes
    aspect ratio to match that of the image. If *extent* is
    not *None*, the axes aspect ratio is changed to match that
    of the extent.

    If *None*, default to rc ``image.aspect`` value.

  *interpolation*:

    Acceptable values are *None*, 'nearest', 'bilinear',
      'bicubic', 'spline16', 'spline36', 'hanning', 'hamming',
      'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian',
      'bessel', 'mitchell', 'sinc', 'lanczos',

    If *interpolation* is *None*, default to rc
    ``image.interpolation``. See also the *filternorm* and
    *filterrad* parameters

  *norm*: [ None | Normalize ]
    An :class:`matplotlib.colors.Normalize` instance; if
    *None*, default is ``normalization()``.  This scales
    luminance -> 0-1

    *norm* is only used for an MxN float array.

  *vmin*/*vmax*: [ None | scalar ]
    Used to scale a luminance image to 0-1.  If either is
    *None*, the min and max of the luminance values will be
    used.  Note if *norm* is not *None*, the settings for
    *vmin* and *vmax* will be ignored.

  *alpha*: scalar
    The alpha blending value, between 0 (transparent) and 1 (opaque)

  *origin*: [ None | 'upper' | 'lower' ]
    Place the [0,0] index of the array in the upper left or lower left
    corner of the axes. If *None*, default to rc ``image.origin``.

  *extent*: [ None | scalars (left, right, bottom, top) ]
    Eata values of the axes.  The default assigns zero-based row,
    column indices to the *x*, *y* centers of the pixels.

  *shape*: [ None | scalars (columns, rows) ]
    For raw buffer images

  *filternorm*:
    A parameter for the antigrain image resize filter.  From the
    antigrain documentation, if *filternorm* = 1, the filter normalizes
    integer values and corrects the rounding errors. It doesn't do
    anything with the source floating point values, it corrects only
    integers according to the rule of 1.0 which means that any sum of
    pixel weights must be equal to 1.0.  So, the filter function must
    produce a graph of the proper shape.

  *filterrad*:
    The filter radius for filters that have a radius
    parameter, i.e. when interpolation is one of: 'sinc',
    'lanczos' or 'blackman'

Additional kwargs are :class:`~matplotlib.artist.Artist` properties:

%(Artist)s

**Example:**

.. plot:: mpl_examples/pylab_examples/image_demo.py


return self.yaxis<EOL>


return cbook.silent_list('<STR_LIT>',<EOL>self.yaxis.get_minorticklabels())<EOL>


def boxplot(self, x, notch=<NUM_LIT:0>, sym='<STR_LIT>', vert=<NUM_LIT:1>, whis=<NUM_LIT>,<EOL>positions=None, widths=None):

if not self._hold: self.cla()<EOL>holdStatus = self._hold<EOL>whiskers, caps, boxes, medians, fliers = [], [], [], [], []<EOL>if hasattr(x, '<STR_LIT>'):<EOL><INDENT>if len(x.shape) == <NUM_LIT:1>:<EOL><INDENT>if hasattr(x[<NUM_LIT:0>], '<STR_LIT>'):<EOL><INDENT>x = list(x)<EOL><DEDENT>else:<EOL><INDENT>x = [x,]<EOL><DEDENT><DEDENT>elif len(x.shape) == <NUM_LIT:2>:<EOL><INDENT>nr, nc = x.shape<EOL>if nr == <NUM_LIT:1>:<EOL><INDENT>x = [x]<EOL><DEDENT>elif nc == <NUM_LIT:1>:<EOL><INDENT>x = [x.ravel()]<EOL><DEDENT>else:<EOL><INDENT>x = [x[:,i] for i in range(nc)]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>if not hasattr(x[<NUM_LIT:0>], '<STR_LIT>'):<EOL><INDENT>x = [x]<EOL><DEDENT>col = len(x)<EOL>if positions is None:<EOL><INDENT>positions = list(range(<NUM_LIT:1>, col + <NUM_LIT:1>))<EOL><DEDENT>if widths is None:<EOL><INDENT>distance = max(positions) - min(positions)<EOL>widths = min(<NUM_LIT>*max(distance,<NUM_LIT:1.0>), <NUM_LIT:0.5>)<EOL><DEDENT>if isinstance(widths, float) or isinstance(widths, int):<EOL><INDENT>widths = np.ones((col,), float) * widths<EOL><DEDENT>self.hold(True)<EOL>for i,pos in enumerate(positions):<EOL><INDENT>d = np.ravel(x[i])<EOL>row = len(d)<EOL>q1, med, q3 = mlab.prctile(d,[<NUM_LIT>,<NUM_LIT:50>,<NUM_LIT>])<EOL>iq = q3 - q1<EOL>hi_val = q3 + whis*iq<EOL>wisk_hi = np.compress( d <= hi_val , d )<EOL>if len(wisk_hi) == <NUM_LIT:0>:<EOL><INDENT>wisk_hi = q3<EOL><DEDENT>else:<EOL><INDENT>wisk_hi = max(wisk_hi)<EOL><DEDENT>lo_val = q1 - whis*iq<EOL>wisk_lo = np.compress( d >= lo_val, d )<EOL>if len(wisk_lo) == <NUM_LIT:0>:<EOL><INDENT>wisk_lo = q1<EOL><DEDENT>else:<EOL><INDENT>wisk_lo = min(wisk_lo)<EOL><DEDENT>flier_hi = []<EOL>flier_lo = []<EOL>flier_hi_x = []<EOL>flier_lo_x = []<EOL>if len(sym) != <NUM_LIT:0>:<EOL><INDENT>flier_hi = np.compress( d > wisk_hi, d )<EOL>flier_lo = np.compress( d < wisk_lo, d )<EOL>flier_hi_x = np.ones(flier_hi.shape[<NUM_LIT:0>]) * pos<EOL>flier_lo_x = np.ones(flier_lo.shape[<NUM_LIT:0>]) * pos<EOL><DEDENT>box_x_min = pos - widths[i] * <NUM_LIT:0.5><EOL>box_x_max = pos + widths[i] * <NUM_LIT:0.5><EOL>wisk_x = np.ones(<NUM_LIT:2>) * pos<EOL>cap_x_min = pos - widths[i] * <NUM_LIT><EOL>cap_x_max = pos + widths[i] * <NUM_LIT><EOL>cap_x = [cap_x_min, cap_x_max]<EOL>med_y = [med, med]<EOL>if notch == <NUM_LIT:0>:<EOL><INDENT>box_x = [box_x_min, box_x_max, box_x_max, box_x_min, box_x_min ]<EOL>box_y = [q1, q1, q3, q3, q1 ]<EOL>med_x = [box_x_min, box_x_max]<EOL><DEDENT>else:<EOL><INDENT>notch_max = med + <NUM_LIT>*iq/np.sqrt(row)<EOL>notch_min = med - <NUM_LIT>*iq/np.sqrt(row)<EOL>if notch_max > q3:<EOL><INDENT>notch_max = q3<EOL><DEDENT>if notch_min < q1:<EOL><INDENT>notch_min = q1<EOL><DEDENT>box_x = [box_x_min, box_x_max, box_x_max, cap_x_max, box_x_max,<EOL>box_x_max, box_x_min, box_x_min, cap_x_min, box_x_min,<EOL>box_x_min ]<EOL>box_y = [q1, q1, notch_min, med, notch_max, q3, q3, notch_max,<EOL>med, notch_min, q1]<EOL>med_x = [cap_x_min, cap_x_max]<EOL>med_y = [med, med]<EOL><DEDENT>if vert:<EOL><INDENT>def doplot(*args):<EOL><INDENT>return self.plot(*args)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>def doplot(*args):<EOL><INDENT>shuffled = []<EOL>for i in range(<NUM_LIT:0>, len(args), <NUM_LIT:3>):<EOL><INDENT>shuffled.extend([args[i+<NUM_LIT:1>], args[i], args[i+<NUM_LIT:2>]])<EOL><DEDENT>return self.plot(*shuffled)<EOL><DEDENT><DEDENT>whiskers.extend(doplot(wisk_x, [q1, wisk_lo], '<STR_LIT>',<EOL>wisk_x, [q3, wisk_hi], '<STR_LIT>'))<EOL>caps.extend(doplot(cap_x, [wisk_hi, wisk_hi], '<STR_LIT>',<EOL>cap_x, [wisk_lo, wisk_lo], '<STR_LIT>'))<EOL>boxes.extend(doplot(box_x, box_y, '<STR_LIT>'))<EOL>medians.extend(doplot(med_x, med_y, '<STR_LIT>'))<EOL>fliers.extend(doplot(flier_hi_x, flier_hi, sym,<EOL>flier_lo_x, flier_lo, sym))<EOL><DEDENT>if <NUM_LIT:1> == vert:<EOL><INDENT>setticks, setlim = self.set_xticks, self.set_xlim<EOL><DEDENT>else:<EOL><INDENT>setticks, setlim = self.set_yticks, self.set_ylim<EOL><DEDENT>newlimits = min(positions)-<NUM_LIT:0.5>, max(positions)+<NUM_LIT:0.5><EOL>setlim(newlimits)<EOL>setticks(positions)<EOL>self.hold(holdStatus)<EOL>return dict(whiskers=whiskers, caps=caps, boxes=boxes,<EOL>medians=medians, fliers=fliers)<EOL>

call signature::

  boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
          positions=None, widths=None)

Make a box and whisker plot for each column of *x* or each
vector in sequence *x*.  The box extends from the lower to
upper quartile values of the data, with a line at the median.
The whiskers extend from the box to show the range of the
data.  Flier points are those past the end of the whiskers.

- *notch* = 0 (default) produces a rectangular box plot.
- *notch* = 1 will produce a notched box plot

*sym* (default 'b+') is the default symbol for flier points.
Enter an empty string ('') if you don't want to show fliers.

- *vert* = 1 (default) makes the boxes vertical.
- *vert* = 0 makes horizontal boxes.  This seems goofy, but
  that's how Matlab did it.

*whis* (default 1.5) defines the length of the whiskers as
a function of the inner quartile range.  They extend to the
most extreme data point within ( ``whis*(75%-25%)`` ) data range.

*positions* (default 1,2,...,n) sets the horizontal positions of
the boxes. The ticks and limits are automatically set to match
the positions.

*widths* is either a scalar or a vector and sets the width of
each box. The default is 0.5, or ``0.15*(distance between extreme
positions)`` if that is smaller.

*x* is an array or a sequence of vectors.

Returns a dictionary mapping each component of the boxplot
to a list of the :class:`matplotlib.lines.Line2D`
instances created.

**Example:**

.. plot:: pyplots/boxplot_demo.py


ax2 = self.figure.add_axes(self.get_position(True), sharey=self,<EOL>frameon=False)<EOL>ax2.xaxis.tick_top()<EOL>ax2.xaxis.set_label_position('<STR_LIT>')<EOL>self.xaxis.tick_bottom()<EOL>return ax2<EOL>

call signature::

  ax = twiny()

create a twin of Axes for generating a plot with a shared
y-axis but independent x axis.  The x-axis of self will have
ticks on bottom and the returned axes will have ticks on the
top


def hexbin(self, x, y, C = None, gridsize = <NUM_LIT:100>, bins = None,<EOL>xscale = '<STR_LIT>', yscale = '<STR_LIT>',<EOL>cmap=None, norm=None, vmin=None, vmax=None,<EOL>alpha=<NUM_LIT:1.0>, linewidths=None, edgecolors='<STR_LIT:none>',<EOL>reduce_C_function = np.mean,<EOL>**kwargs):

if not self._hold: self.cla()<EOL>self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)<EOL>x, y, C = cbook.delete_masked_points(x, y, C)<EOL>if iterable(gridsize):<EOL><INDENT>nx, ny = gridsize<EOL><DEDENT>else:<EOL><INDENT>nx = gridsize<EOL>ny = int(nx/math.sqrt(<NUM_LIT:3>))<EOL><DEDENT>x = np.array(x, float)<EOL>y = np.array(y, float)<EOL>if xscale=='<STR_LIT>':<EOL><INDENT>x = np.log10(x)<EOL><DEDENT>if yscale=='<STR_LIT>':<EOL><INDENT>y = np.log10(y)<EOL><DEDENT>xmin = np.amin(x)<EOL>xmax = np.amax(x)<EOL>ymin = np.amin(y)<EOL>ymax = np.amax(y)<EOL>padding = <NUM_LIT> * (xmax - xmin)<EOL>xmin -= padding<EOL>xmax += padding<EOL>sx = (xmax-xmin) / nx<EOL>sy = (ymax-ymin) / ny<EOL>x = (x-xmin)/sx<EOL>y = (y-ymin)/sy<EOL>ix1 = np.round(x).astype(int)<EOL>iy1 = np.round(y).astype(int)<EOL>ix2 = np.floor(x).astype(int)<EOL>iy2 = np.floor(y).astype(int)<EOL>nx1 = nx + <NUM_LIT:1><EOL>ny1 = ny + <NUM_LIT:1><EOL>nx2 = nx<EOL>ny2 = ny<EOL>n = nx1*ny1+nx2*ny2<EOL>d1 = (x-ix1)**<NUM_LIT:2> + <NUM_LIT> * (y-iy1)**<NUM_LIT:2><EOL>d2 = (x-ix2-<NUM_LIT:0.5>)**<NUM_LIT:2> + <NUM_LIT> * (y-iy2-<NUM_LIT:0.5>)**<NUM_LIT:2><EOL>bdist = (d1<d2)<EOL>if C is None:<EOL><INDENT>accum = np.zeros(n)<EOL>lattice1 = accum[:nx1*ny1]<EOL>lattice2 = accum[nx1*ny1:]<EOL>lattice1.shape = (nx1,ny1)<EOL>lattice2.shape = (nx2,ny2)<EOL>for i in range(len(x)):<EOL><INDENT>if bdist[i]:<EOL><INDENT>lattice1[ix1[i], iy1[i]]+=<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>lattice2[ix2[i], iy2[i]]+=<NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>lattice1 = np.empty((nx1,ny1),dtype=object)<EOL>for i in range(nx1):<EOL><INDENT>for j in range(ny1):<EOL><INDENT>lattice1[i,j] = []<EOL><DEDENT><DEDENT>lattice2 = np.empty((nx2,ny2),dtype=object)<EOL>for i in range(nx2):<EOL><INDENT>for j in range(ny2):<EOL><INDENT>lattice2[i,j] = []<EOL><DEDENT><DEDENT>for i in range(len(x)):<EOL><INDENT>if bdist[i]:<EOL><INDENT>lattice1[ix1[i], iy1[i]].append( C[i] )<EOL><DEDENT>else:<EOL><INDENT>lattice2[ix2[i], iy2[i]].append( C[i] )<EOL><DEDENT><DEDENT>for i in range(nx1):<EOL><INDENT>for j in range(ny1):<EOL><INDENT>vals = lattice1[i,j]<EOL>if len(vals):<EOL><INDENT>lattice1[i,j] = reduce_C_function( vals )<EOL><DEDENT>else:<EOL><INDENT>lattice1[i,j] = np.nan<EOL><DEDENT><DEDENT><DEDENT>for i in range(nx2):<EOL><INDENT>for j in range(ny2):<EOL><INDENT>vals = lattice2[i,j]<EOL>if len(vals):<EOL><INDENT>lattice2[i,j] = reduce_C_function( vals )<EOL><DEDENT>else:<EOL><INDENT>lattice2[i,j] = np.nan<EOL><DEDENT><DEDENT><DEDENT>accum = np.hstack((<EOL>lattice1.astype(float).ravel(), lattice2.astype(float).ravel()))<EOL>good_idxs = ~np.isnan(accum)<EOL><DEDENT>px = xmin + sx * np.array([ <NUM_LIT:0.5>, <NUM_LIT:0.5>, <NUM_LIT:0.0>, -<NUM_LIT:0.5>, -<NUM_LIT:0.5>,  <NUM_LIT:0.0>])<EOL>py = ymin + sy * np.array([-<NUM_LIT:0.5>, <NUM_LIT:0.5>, <NUM_LIT:1.0>,  <NUM_LIT:0.5>, -<NUM_LIT:0.5>, -<NUM_LIT:1.0>]) / <NUM_LIT><EOL>polygons = np.zeros((<NUM_LIT:6>, n, <NUM_LIT:2>), float)<EOL>polygons[:,:nx1*ny1,<NUM_LIT:0>] = np.repeat(np.arange(nx1), ny1)<EOL>polygons[:,:nx1*ny1,<NUM_LIT:1>] = np.tile(np.arange(ny1), nx1)<EOL>polygons[:,nx1*ny1:,<NUM_LIT:0>] = np.repeat(np.arange(nx2) + <NUM_LIT:0.5>, ny2)<EOL>polygons[:,nx1*ny1:,<NUM_LIT:1>] = np.tile(np.arange(ny2), nx2) + <NUM_LIT:0.5><EOL>if C is not None:<EOL><INDENT>polygons = polygons[:,good_idxs,:]<EOL>accum = accum[good_idxs]<EOL><DEDENT>polygons = np.transpose(polygons, axes=[<NUM_LIT:1>,<NUM_LIT:0>,<NUM_LIT:2>])<EOL>polygons[:,:,<NUM_LIT:0>] *= sx<EOL>polygons[:,:,<NUM_LIT:1>] *= sy<EOL>polygons[:,:,<NUM_LIT:0>] += px<EOL>polygons[:,:,<NUM_LIT:1>] += py<EOL>if xscale=='<STR_LIT>':<EOL><INDENT>polygons[:,:,<NUM_LIT:0>] = <NUM_LIT:10>**(polygons[:,:,<NUM_LIT:0>])<EOL>xmin = <NUM_LIT:10>**xmin<EOL>xmax = <NUM_LIT:10>**xmax<EOL>self.set_xscale('<STR_LIT>')<EOL><DEDENT>if yscale=='<STR_LIT>':<EOL><INDENT>polygons[:,:,<NUM_LIT:1>] = <NUM_LIT:10>**(polygons[:,:,<NUM_LIT:1>])<EOL>ymin = <NUM_LIT:10>**ymin<EOL>ymax = <NUM_LIT:10>**ymax<EOL>self.set_yscale('<STR_LIT>')<EOL><DEDENT>if edgecolors=='<STR_LIT:none>':<EOL><INDENT>edgecolors = '<STR_LIT>'<EOL><DEDENT>collection = mcoll.PolyCollection(<EOL>polygons,<EOL>edgecolors = edgecolors,<EOL>linewidths = linewidths,<EOL>transOffset = self.transData,<EOL>)<EOL>if bins=='<STR_LIT>':<EOL><INDENT>accum = np.log10(accum+<NUM_LIT:1>)<EOL><DEDENT>elif bins!=None:<EOL><INDENT>if not iterable(bins):<EOL><INDENT>minimum, maximum = min(accum), max(accum)<EOL>bins-=<NUM_LIT:1> <EOL>bins = minimum + (maximum-minimum)*np.arange(bins)/bins<EOL><DEDENT>bins = np.sort(bins)<EOL>accum = bins.searchsorted(accum)<EOL><DEDENT>if norm is not None: assert(isinstance(norm, mcolors.Normalize))<EOL>if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))<EOL>collection.set_array(accum)<EOL>collection.set_cmap(cmap)<EOL>collection.set_norm(norm)<EOL>collection.set_alpha(alpha)<EOL>collection.update(kwargs)<EOL>if vmin is not None or vmax is not None:<EOL><INDENT>collection.set_clim(vmin, vmax)<EOL><DEDENT>else:<EOL><INDENT>collection.autoscale_None()<EOL><DEDENT>corners = ((xmin, ymin), (xmax, ymax))<EOL>self.update_datalim( corners)<EOL>self.autoscale_view()<EOL>self.add_collection(collection)<EOL>return collection<EOL>

call signature::

  hexbin(x, y, C = None, gridsize = 100, bins = None,
         xscale = 'linear', yscale = 'linear',
         cmap=None, norm=None, vmin=None, vmax=None,
         alpha=1.0, linewidths=None, edgecolors='none'
         reduce_C_function = np.mean,
         **kwargs)

Make a hexagonal binning plot of *x* versus *y*, where *x*,
*y* are 1-D sequences of the same length, *N*. If *C* is None
(the default), this is a histogram of the number of occurences
of the observations at (x[i],y[i]).

If *C* is specified, it specifies values at the coordinate
(x[i],y[i]). These values are accumulated for each hexagonal
bin and then reduced according to *reduce_C_function*, which
defaults to numpy's mean function (np.mean). (If *C* is
specified, it must also be a 1-D sequence of the same length
as *x* and *y*.)

*x*, *y* and/or *C* may be masked arrays, in which case only
unmasked points will be plotted.

Optional keyword arguments:

  *gridsize*: [ 100 | integer ]
    The number of hexagons in the *x*-direction, default is
    100. The corresponding number of hexagons in the
    *y*-direction is chosen such that the hexagons are
    approximately regular. Alternatively, gridsize can be a
    tuple with two elements specifying the number of hexagons
    in the *x*-direction and the *y*-direction.

  *bins*: [ None | 'log' | integer | sequence ]
    If *None*, no binning is applied; the color of each hexagon
    directly corresponds to its count value.

    If 'log', use a logarithmic scale for the color
    map. Internally, :math:`log_{10}(i+1)` is used to
    determine the hexagon color.

    If an integer, divide the counts in the specified number
    of bins, and color the hexagons accordingly.

    If a sequence of values, the values of the lower bound of
    the bins to be used.

  *xscale*: [ 'linear' | 'log' ]
    Use a linear or log10 scale on the horizontal axis.

  *scale*: [ 'linear' | 'log' ]
    Use a linear or log10 scale on the vertical axis.

Other keyword arguments controlling color mapping and normalization
arguments:

  *cmap*: [ None | Colormap ]
    a :class:`matplotlib.cm.Colormap` instance. If *None*,
    defaults to rc ``image.cmap``.

  *norm*: [ None | Normalize ]
    :class:`matplotlib.colors.Normalize` instance is used to
    scale luminance data to 0,1.

  *vmin*/*vmax*: scalar
    *vmin* and *vmax* are used in conjunction with *norm* to normalize
    luminance data.  If either are *None*, the min and max of the color
    array *C* is used.  Note if you pass a norm instance, your settings
    for *vmin* and *vmax* will be ignored.

  *alpha*: scalar
    the alpha value for the patches

  *linewidths*: [ None | scalar ]
    If *None*, defaults to rc lines.linewidth. Note that this
    is a tuple, and if you set the linewidths argument you
    must set it as a sequence of floats, as required by
    :class:`~matplotlib.collections.RegularPolyCollection`.

Other keyword arguments controlling the Collection properties:

  *edgecolors*: [ None | mpl color | color sequence ]
    If 'none', draws the edges in the same color as the fill color.
    This is the default, as it avoids unsightly unpainted pixels
    between the hexagons.

    If *None*, draws the outlines in the default color.

    If a matplotlib color arg or sequence of rgba tuples, draws the
    outlines in the specified color.

Here are the standard descriptions of all the
:class:`~matplotlib.collections.Collection` kwargs:

%(Collection)s

The return value is a
:class:`~matplotlib.collections.PolyCollection` instance; use
:meth:`~matplotlib.collection.PolyCollection.get_array` on
this :class:`~matplotlib.collections.PolyCollection` to get
the counts in each hexagon.

**Example:**

.. plot:: mpl_examples/pylab_examples/hexbin_demo.py


del self._pan_start<EOL>

Called when a pan operation completes (when the mouse button
is up.)

.. note::
    Intended to be overridden by new projection types.


return self.xaxis<EOL>


raise DeprecationWarning('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>


return cbook.silent_list('<STR_LIT>',<EOL>self.yaxis.get_majorticklabels())<EOL>

Get the xtick labels as a list of Text instances


def text(self, x, y, s, fontdict=None,<EOL>withdash=False, **kwargs):

default = {<EOL>'<STR_LIT>' : '<STR_LIT>',<EOL>'<STR_LIT>' : '<STR_LIT:left>',<EOL>'<STR_LIT>' : self.transData,<EOL>}<EOL>if withdash:<EOL><INDENT>t = mtext.TextWithDash(<EOL>x=x, y=y, text=s,<EOL>)<EOL><DEDENT>else:<EOL><INDENT>t = mtext.Text(<EOL>x=x, y=y, text=s,<EOL>)<EOL><DEDENT>self._set_artist_props(t)<EOL>t.update(default)<EOL>if fontdict is not None: t.update(fontdict)<EOL>t.update(kwargs)<EOL>self.texts.append(t)<EOL>t._remove_method = lambda h: self.texts.remove(h)<EOL>if '<STR_LIT>' in kwargs:  t.set_clip_box(self.bbox)<EOL>return t<EOL>

call signature::

   text(x, y, s, fontdict=None, **kwargs)

 Add text in string *s* to axis at location *x*, *y*, data
 coordinates.

 Keyword arguments:

   *fontdict*:
     A dictionary to override the default text properties.
     If *fontdict* is *None*, the defaults are determined by your rc
     parameters.

   *withdash*: [ False | True ]
     Creates a :class:`~matplotlib.text.TextWithDash` instance
     instead of a :class:`~matplotlib.text.Text` instance.

 Individual keyword arguments can be used to override any given
 parameter::

     text(x, y, s, fontsize=12)

 The default transform specifies that text is in data coords,
 alternatively, you can specify text in axis coords (0,0 is
 lower-left and 1,1 is upper-right).  The example below places
 text in the center of the axes::

     text(0.5, 0.5,'matplotlib',
          horizontalalignment='center',
          verticalalignment='center',
          transform = ax.transAxes)

You can put a rectangular box around the text instance (eg. to
set a background color) by using the keyword *bbox*.  *bbox* is
a dictionary of :class:`matplotlib.patches.Rectangle`
properties.  For example::

  text(x, y, s, bbox=dict(facecolor='red', alpha=0.5))

Valid kwargs are :class:`matplotlib.text.Text` properties:

%(Text)s


self._axisbelow = b<EOL>

Set whether the axis ticks and gridlines are above or below most artists

ACCEPTS: [ *True* | *False* ]


def format_deltas(key, dx, dy):<EOL><INDENT>if key=='<STR_LIT>':<EOL><INDENT>if(abs(dx)>abs(dy)):<EOL><INDENT>dy = dx<EOL><DEDENT>else:<EOL><INDENT>dx = dy<EOL><DEDENT><DEDENT>elif key=='<STR_LIT:x>':<EOL><INDENT>dy = <NUM_LIT:0><EOL><DEDENT>elif key=='<STR_LIT:y>':<EOL><INDENT>dx = <NUM_LIT:0><EOL><DEDENT>elif key=='<STR_LIT>':<EOL><INDENT>if <NUM_LIT:2>*abs(dx) < abs(dy):<EOL><INDENT>dx=<NUM_LIT:0><EOL><DEDENT>elif <NUM_LIT:2>*abs(dy) < abs(dx):<EOL><INDENT>dy=<NUM_LIT:0><EOL><DEDENT>elif(abs(dx)>abs(dy)):<EOL><INDENT>dy=dy/abs(dy)*abs(dx)<EOL><DEDENT>else:<EOL><INDENT>dx=dx/abs(dx)*abs(dy)<EOL><DEDENT><DEDENT>return (dx,dy)<EOL><DEDENT>p = self._pan_start<EOL>dx = x - p.x<EOL>dy = y - p.y<EOL>if dx == <NUM_LIT:0> and dy == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if button == <NUM_LIT:1>:<EOL><INDENT>dx, dy = format_deltas(key, dx, dy)<EOL>result = p.bbox.translated(-dx, -dy).transformed(p.trans_inverse)<EOL><DEDENT>elif button == <NUM_LIT:3>:<EOL><INDENT>try:<EOL><INDENT>dx = -dx / float(self.bbox.width)<EOL>dy = -dy / float(self.bbox.height)<EOL>dx, dy = format_deltas(key, dx, dy)<EOL>if self.get_aspect() != '<STR_LIT>':<EOL><INDENT>dx = <NUM_LIT:0.5> * (dx + dy)<EOL>dy = dx<EOL><DEDENT>alpha = np.power(<NUM_LIT>, (dx, dy))<EOL>start = p.trans_inverse.transform_point((p.x, p.y))<EOL>lim_points = p.lim.get_points()<EOL>result = start + alpha * (lim_points - start)<EOL>result = mtransforms.Bbox(result)<EOL><DEDENT>except OverflowError:<EOL><INDENT>warnings.warn('<STR_LIT>')<EOL>return<EOL><DEDENT><DEDENT>self.set_xlim(*result.intervalx)<EOL>self.set_ylim(*result.intervaly)<EOL>

Called when the mouse moves during a pan operation.

*button* is the mouse button number:

* 1: LEFT
* 2: MIDDLE
* 3: RIGHT

*key* is a "shift" key

*x*, *y* are the mouse coordinates in display coords.

.. note::
    Intended to be overridden by new projection types.