data = np.zeros((M,N))*<NUM_LIT:0.><EOL>for i in range(int(M*N*frac)):<EOL><INDENT>x = np.random.randint(<NUM_LIT:0>,M-<NUM_LIT:1>)<EOL>y = np.random.randint(<NUM_LIT:0>,N-<NUM_LIT:1>)<EOL>data[x,y] = np.random.rand()<EOL><DEDENT>return data<EOL>

Return a *M* x *N* sparse matrix with *frac* elements randomly
filled.


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


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)


def fftsurr(x, detrend=detrend_none, window=window_none):

if cbook.iterable(window):<EOL><INDENT>x=window*detrend(x)<EOL><DEDENT>else:<EOL><INDENT>x = window(detrend(x))<EOL><DEDENT>z = np.fft.fft(x)<EOL>a = <NUM_LIT>*np.pi*<NUM_LIT><EOL>phase = a * np.random.rand(len(x))<EOL>z = z*np.exp(phase)<EOL>return np.fft.ifft(z).real<EOL>

Compute an FFT phase randomized surrogate of *x*.


return np.mean(np.log(np.absolute(fprime(x))))<EOL>

*x* is a very long trajectory from a map, and *fprime* returns the
derivative of *x*.

Returns :
.. math::

    \lambda = \\frac{1}{n}\\sum \\ln|f^'(x_i)|

.. seealso::
    Sec 10.5 Strogatz (1994) "Nonlinear Dynamics and Chaos".

    `Wikipedia article on Lyapunov Exponent
    <http://en.wikipedia.org/wiki/Lyapunov_exponent>`_.

.. note::
    What the function here calculates may not be what you really want;
    *caveat emptor*.

    It also seems that this function's name is badly misspelled.


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


def save(fname, X, fmt='<STR_LIT>',delimiter='<STR_LIT:U+0020>'):

if cbook.is_string_like(fname):<EOL><INDENT>if fname.endswith('<STR_LIT>'):<EOL><INDENT>import gzip<EOL>fh = gzip.open(fname,'<STR_LIT:wb>')<EOL><DEDENT>else:<EOL><INDENT>fh = file(fname,'<STR_LIT:w>')<EOL><DEDENT><DEDENT>elif hasattr(fname, '<STR_LIT>'):<EOL><INDENT>fh = fname<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>X = np.asarray(X)<EOL>origShape = None<EOL>if X.ndim == <NUM_LIT:1>:<EOL><INDENT>origShape = X.shape<EOL>X.shape = len(X), <NUM_LIT:1><EOL><DEDENT>for row in X:<EOL><INDENT>fh.write(delimiter.join([fmt%val for val in row]) + '<STR_LIT:\n>')<EOL><DEDENT>if origShape is not None:<EOL><INDENT>X.shape = origShape<EOL><DEDENT>

Save the data in *X* to file *fname* using *fmt* string to convert the
data to strings.

*fname* can be a filename or a file handle.  If the filename ends
in '.gz', the file is automatically saved in compressed gzip
format.  The :func:`load` function understands gzipped files
transparently.

Example usage::

  save('test.out', X)         # X is an array
  save('test1.out', (x,y,z))  # x,y,z equal sized 1D arrays
  save('test2.out', x)        # x is 1D
  save('test3.out', x, fmt='%1.4e')  # use exponential notation

*delimiter* is used to separate the fields, eg. *delimiter* ','
for comma-separated values.


def load(fname,comments='<STR_LIT:#>',delimiter=None, converters=None,skiprows=<NUM_LIT:0>,<EOL>usecols=None, unpack=False, dtype=np.float_):

if converters is None: converters = {}<EOL>fh = cbook.to_filehandle(fname)<EOL>X = []<EOL>if delimiter=='<STR_LIT:U+0020>':<EOL><INDENT>def splitfunc(x):<EOL><INDENT>return x.split()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>def splitfunc(x):<EOL><INDENT>return x.split(delimiter)<EOL><DEDENT><DEDENT>converterseq = None<EOL>for i,line in enumerate(fh):<EOL><INDENT>if i<skiprows: continue<EOL>line = line.split(comments, <NUM_LIT:1>)[<NUM_LIT:0>].strip()<EOL>if not len(line): continue<EOL>if converterseq is None:<EOL><INDENT>converterseq = [converters.get(j,float)<EOL>for j,val in enumerate(splitfunc(line))]<EOL><DEDENT>if usecols is not None:<EOL><INDENT>vals = splitfunc(line)<EOL>row = [converterseq[j](vals[j]) for j in usecols]<EOL><DEDENT>else:<EOL><INDENT>row = [converterseq[j](val)<EOL>for j,val in enumerate(splitfunc(line))]<EOL><DEDENT>thisLen = len(row)<EOL>X.append(row)<EOL><DEDENT>X = np.array(X, dtype)<EOL>r,c = X.shape<EOL>if r==<NUM_LIT:1> or c==<NUM_LIT:1>:<EOL><INDENT>X.shape = max(r,c),<EOL><DEDENT>if unpack: return X.transpose()<EOL>else: return X<EOL>

Load ASCII data from *fname* into an array and return the array.

The data must be regular, same number of values in every row

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

matfile data is not supported; for that, use :mod:`scipy.io.mio`
module.

Example usage::

  X = load('test.dat')  # data in two columns
  t = X[:,0]
  y = X[:,1]

Alternatively, you can do the same with "unpack"; see below::

  X = load('test.dat')    # a matrix of data
  x = load('test.dat')    # a single column of data

- *comments*: the character used to indicate the start of a comment
  in the file

- *delimiter* is a string-like character used to seperate values
  in the file. If *delimiter* is unspecified or *None*, any
  whitespace string is a separator.

- *converters*, if not *None*, is a dictionary mapping column number to
  a function that will convert that column to a float (or the optional
  *dtype* if specified).  Eg, if column 0 is a date string::

    converters = {0:datestr2num}

- *skiprows* is the number of rows from the top to skip.

- *usecols*, if not *None*, is a sequence of integer column indexes to
  extract where 0 is the first column, eg ``usecols=[1,4,5]`` to extract
  just the 2nd, 5th and 6th columns

- *unpack*, if *True*, will transpose the matrix allowing you to unpack
  into named arguments on the left hand side::

    t,y = load('test.dat', unpack=True) # for  two column data
    x,y,z = load('somefile.dat', usecols=[3,5,7], unpack=True)

- *dtype*: the array will have this dtype.  default: ``numpy.float_``

.. seealso::
    See :file:`examples/pylab_examples/load_converter.py` in the source tree:
       Exercises many of these options.


<EOL>x=np.asarray(x, np.float_)<EOL>y=np.asarray(y, np.float_)<EOL>yp=np.zeros(y.shape, np.float_)<EOL>dx=x[<NUM_LIT:1>:] - x[:-<NUM_LIT:1>]<EOL>dy=y[<NUM_LIT:1>:] - y[:-<NUM_LIT:1>]<EOL>dydx = dy/dx<EOL>yp[<NUM_LIT:1>:-<NUM_LIT:1>] = (dydx[:-<NUM_LIT:1>] * dx[<NUM_LIT:1>:] + dydx[<NUM_LIT:1>:] * dx[:-<NUM_LIT:1>])/(dx[<NUM_LIT:1>:] + dx[:-<NUM_LIT:1>])<EOL>yp[<NUM_LIT:0>] = <NUM_LIT> * dy[<NUM_LIT:0>]/dx[<NUM_LIT:0>] - yp[<NUM_LIT:1>]<EOL>yp[-<NUM_LIT:1>] = <NUM_LIT> * dy[-<NUM_LIT:1>]/dx[-<NUM_LIT:1>] - yp[-<NUM_LIT:2>]<EOL>return yp<EOL>

SLOPES calculate the slope y'(x) Given data vectors X and Y SLOPES
calculates Y'(X), i.e the slope of a curve Y(X). The slope is
estimated using the slope obtained from that of a parabola through
any three consecutive points.

This method should be superior to that described in the appendix
of A CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russel
W. Stineman (Creative Computing July 1980) in at least one aspect:

Circles for interpolation demand a known aspect ratio between x-
and y-values.  For many functions, however, the abscissa are given
in different dimensions, so an aspect ratio is completely
arbitrary.

The parabola method gives very similar results to the circle
method for most regular cases but behaves much better in special
cases

Norbert Nemec, Institute of Theoretical Physics, University or
Regensburg, April 2006 Norbert.Nemec at physik.uni-regensburg.de

(inspired by a original implementation by Halldor Bjornsson,
Icelandic Meteorological Office, March 2006 halldor at vedur.is)


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

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


res, =  np.nonzero(nxutils.points_inside_poly(points, verts))<EOL>return res<EOL>

points is a sequence of x,y points
verts is a sequence of x,y vertices of a poygon

return value is a sequence of indices into points for the points
that are inside the polygon


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)


Nx = len(x)<EOL>if not cbook.iterable(ylower):<EOL><INDENT>ylower = ylower*np.ones(Nx)<EOL><DEDENT>if not cbook.iterable(yupper):<EOL><INDENT>yupper = yupper*np.ones(Nx)<EOL><DEDENT>x = np.concatenate( (x, x[::-<NUM_LIT:1>]) )<EOL>y = np.concatenate( (yupper, ylower[::-<NUM_LIT:1>]) )<EOL>return x,y<EOL>

given a sequence of x, ylower and yupper, return the polygon that
fills the regions between them.  ylower or yupper can be scalar or
iterable.  If they are iterable, they must be equal in length to x

return value is x, y arrays for use with Axes.fill


if type(x) is np.ndarray:<EOL><INDENT>return exp(np.clip(x,exp_safe_MIN,exp_safe_MAX))<EOL><DEDENT>else:<EOL><INDENT>return math.exp(x)<EOL><DEDENT>

Compute exponentials which safely underflow to zero.

Slow, but convenient to use. Note that numpy provides proper
floating point exception handling with access to the underlying
hardware.


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(...))``.


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

Return an array of zeros of the shape and typecode of *a*.


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

Return the sum of all the elements of *a*, flattened out.

It uses ``a.flat``, and if *a* is not contiguous, a call to
``ravel(a)`` is made.


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

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


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.


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


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

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

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


<EOL>if p=='<STR_LIT>':<EOL><INDENT>return np.amax(np.absolute(a))<EOL><DEDENT>else:<EOL><INDENT>return (np.sum(np.absolute(a)**p))**(<NUM_LIT:1.0>/p)<EOL><DEDENT>

norm(a,p=2) -> l-p norm of a.flat

Return the l-p norm of *a*, considered as a flat array.  This is NOT a true
matrix norm, since arrays of arbitrary rank are always flattened.

*p* can be a number or the string 'Infinity' to get the L-infinity norm.


<EOL>kw.setdefault('<STR_LIT>',<NUM_LIT:1>)<EOL>endpoint = kw['<STR_LIT>'] != <NUM_LIT:0><EOL>if xfin == None:<EOL><INDENT>xfin = xini + <NUM_LIT:0.0><EOL>xini = <NUM_LIT:0.0><EOL><DEDENT>if delta == None:<EOL><INDENT>delta = <NUM_LIT:1.0><EOL><DEDENT>try:<EOL><INDENT>npts=kw['<STR_LIT>']<EOL>delta=(xfin-xini)/float(npts-endpoint)<EOL><DEDENT>except KeyError:<EOL><INDENT>npts = int(round((xfin-xini)/delta)) + endpoint<EOL><DEDENT>return np.arange(npts)*delta+xini<EOL>

frange([start,] stop[, step, keywords]) -> array of floats

Return a numpy ndarray containing a progression of floats. Similar to
:func:`numpy.arange`, but defaults to a closed interval.

``frange(x0, x1)`` returns ``[x0, x0+1, x0+2, ..., x1]``; *start*
defaults to 0, and the endpoint *is included*. This behavior is
different from that of :func:`range` and
:func:`numpy.arange`. This is deliberate, since :func:`frange`
will probably be more useful for generating lists of points for
function evaluation, and endpoints are often desired in this
use. The usual behavior of :func:`range` can be obtained by
setting the keyword *closed* = 0, in this case, :func:`frange`
basically becomes :func:numpy.arange`.

When *step* is given, it specifies the increment (or
decrement). All arguments can be floating point numbers.

``frange(x0,x1,d)`` returns ``[x0,x0+d,x0+2d,...,xfin]`` where
*xfin* <= *x1*.

:func:`frange` can also be called with the keyword *npts*. This
sets the number of points the list should contain (and overrides
the value *step* might have been given). :func:`numpy.arange`
doesn't offer this option.

Examples::

  >>> frange(3)
  array([ 0.,  1.,  2.,  3.])
  >>> frange(3,closed=0)
  array([ 0.,  1.,  2.])
  >>> frange(1,6,2)
  array([1, 3, 5])   or 1,3,5,7, depending on floating point vagueries
  >>> frange(1,6.5,npts=5)
  array([ 1.   ,  2.375,  3.75 ,  5.125,  6.5  ])


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.


def identity(n, rank=<NUM_LIT:2>, dtype='<STR_LIT:l>', typecode=None):

if typecode is not None:<EOL><INDENT>warnings.warn("<STR_LIT>",<EOL>DeprecationWarning)<EOL>dtype = typecode<EOL><DEDENT>iden = np.zeros((n,)*rank, dtype)<EOL>for i in range(n):<EOL><INDENT>idx = (i,)*rank<EOL>iden[idx] = <NUM_LIT:1><EOL><DEDENT>return iden<EOL>

Returns the identity matrix of shape (*n*, *n*, ..., *n*) (rank *r*).

For ranks higher than 2, this object is simply a multi-index Kronecker
delta::

                        /  1  if i0=i1=...=iR,
    id[i0,i1,...,iR] = -|
                        \  0  otherwise.

Optionally a *dtype* (or typecode) may be given (it defaults to 'l').

Since rank defaults to 2, this function behaves in the default case (when
only *n* is given) like ``numpy.identity(n)`` -- but surprisingly, it is
much faster.


def base_repr (number, base = <NUM_LIT:2>, padding = <NUM_LIT:0>):

chars = '<STR_LIT>'<EOL>if number < base:return (padding - <NUM_LIT:1>) * chars [<NUM_LIT:0>] + chars [int (number)]<EOL>max_exponent = int (math.log (number)/math.log (base))<EOL>max_power = int (base) ** max_exponent<EOL>lead_digit = int (number/max_power)<EOL>return chars [lead_digit] +base_repr (number - max_power * lead_digit, base,max (padding - <NUM_LIT:1>, max_exponent))<EOL>

Return the representation of a *number* in any given *base*.


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.


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.


bin_n = binary_repr(n)[<NUM_LIT:1>:]<EOL>if '<STR_LIT:1>' in bin_n:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>return len(bin_n)<EOL><DEDENT>

Returns the log base 2 of *n* if *n* is a power of 2, zero otherwise.

Note the potential ambiguity if *n* == 1: 2**0 == 1, interpret accordingly.


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.


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.


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

Deprecated - see :func:`numpy.remainder`


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


Deprecated - needs clean room implementation


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>


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>


return rec.view(np.recarray)<EOL>

Return a view of an ndarray as a recarray

.. seealso::

   http://projects.scipy.org/pipermail/numpy-discussion/2008-August/036429.html


def rec_append_field(rec, name, arr, dtype=None):

warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>return rec_append_fields(rec, name, arr, dtype)<EOL>

Return a new record array with field name populated with data from
array *arr*.  This function is Deprecated. Please use
:func:`rec_append_fields`.


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.


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.


<EOL>rowd = dict()<EOL>for i, row in enumerate(r):<EOL><INDENT>key = tuple([row[attr] for attr in groupby])<EOL>rowd.setdefault(key, []).append(i)<EOL><DEDENT>keys = list(rowd.keys())<EOL>keys.sort()<EOL>rows = []<EOL>for key in keys:<EOL><INDENT>row = list(key)<EOL>ind = rowd[key]<EOL>thisr = r[ind]<EOL>row.extend([func(thisr[attr]) for attr, func, outname in stats])<EOL>rows.append(row)<EOL><DEDENT>attrs, funcs, outnames = list(zip(*stats))<EOL>names = list(groupby)<EOL>names.extend(outnames)<EOL>return np.rec.fromrecords(rows, names=names)<EOL>

*r* is a numpy record array

*groupby* is a sequence of record array attribute names that
together form the grouping key.  eg ('date', 'productcode')

*stats* is a sequence of (*attr*, *func*, *outname*) tuples which
will call ``x = func(attr)`` and assign *x* to the record array
output with attribute *outname*.  For example::

  stats = ( ('sales', len, 'numsales'), ('sales', np.mean, 'avgsale') )

Return record array has *dtype* names for each attribute name in
the the *groupby* argument, with the associated group values, and
for each outname name in the *stats* argument, with the associated
stat summary output.


names = list(r.dtype.names)<EOL>arrays = [r[name] for name in names]<EOL>for attr, func, outname in summaryfuncs:<EOL><INDENT>names.append(outname)<EOL>arrays.append(np.asarray(func(r[attr])))<EOL><DEDENT>return np.rec.fromarrays(arrays, names=names)<EOL>

*r* is a numpy record array

*summaryfuncs* is a list of (*attr*, *func*, *outname*) tuples
which will apply *func* to the the array *r*[attr] and assign the
output to a new attribute name *outname*.  The returned record
array is identical to *r*, with extra arrays for each element in
*summaryfuncs*.


def rec_join(key, r1, r2, jointype='<STR_LIT>', defaults=None, r1postfix='<STR_LIT:1>', r2postfix='<STR_LIT:2>'):

if cbook.is_string_like(key):<EOL><INDENT>key = (key, )<EOL><DEDENT>for name in key:<EOL><INDENT>if name not in r1.dtype.names:<EOL><INDENT>raise ValueError('<STR_LIT>'%name)<EOL><DEDENT>if name not in r2.dtype.names:<EOL><INDENT>raise ValueError('<STR_LIT>'%name)<EOL><DEDENT><DEDENT>def makekey(row):<EOL><INDENT>return tuple([row[name] for name in key])<EOL><DEDENT>r1d = dict([(makekey(row),i) for i,row in enumerate(r1)])<EOL>r2d = dict([(makekey(row),i) for i,row in enumerate(r2)])<EOL>r1keys = set(r1d.keys())<EOL>r2keys = set(r2d.keys())<EOL>common_keys = r1keys & r2keys<EOL>r1ind = np.array([r1d[k] for k in common_keys])<EOL>r2ind = np.array([r2d[k] for k in common_keys])<EOL>common_len = len(common_keys)<EOL>left_len = right_len = <NUM_LIT:0><EOL>if jointype == "<STR_LIT>" or jointype == "<STR_LIT>":<EOL><INDENT>left_keys = r1keys.difference(r2keys)<EOL>left_ind = np.array([r1d[k] for k in left_keys])<EOL>left_len = len(left_ind)<EOL><DEDENT>if jointype == "<STR_LIT>":<EOL><INDENT>right_keys = r2keys.difference(r1keys)<EOL>right_ind = np.array([r2d[k] for k in right_keys])<EOL>right_len = len(right_ind)<EOL><DEDENT>def key_desc(name):<EOL><INDENT>'<STR_LIT>'<EOL>dt1 = r1.dtype[name]<EOL>if dt1.type != np.string_:<EOL><INDENT>return (name, dt1.descr[<NUM_LIT:0>][<NUM_LIT:1>])<EOL><DEDENT>dt2 = r1.dtype[name]<EOL>assert dt2==dt1<EOL>if dt1.num>dt2.num:<EOL><INDENT>return (name, dt1.descr[<NUM_LIT:0>][<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>return (name, dt2.descr[<NUM_LIT:0>][<NUM_LIT:1>])<EOL><DEDENT><DEDENT>keydesc = [key_desc(name) for name in key]<EOL>def mapped_r1field(name):<EOL><INDENT>"""<STR_LIT>"""<EOL>if name in key or name not in r2.dtype.names: return name<EOL>else: return name + r1postfix<EOL><DEDENT>def mapped_r2field(name):<EOL><INDENT>"""<STR_LIT>"""<EOL>if name in key or name not in r1.dtype.names: return name<EOL>else: return name + r2postfix<EOL><DEDENT>r1desc = [(mapped_r1field(desc[<NUM_LIT:0>]), desc[<NUM_LIT:1>]) for desc in r1.dtype.descr if desc[<NUM_LIT:0>] not in key]<EOL>r2desc = [(mapped_r2field(desc[<NUM_LIT:0>]), desc[<NUM_LIT:1>]) for desc in r2.dtype.descr if desc[<NUM_LIT:0>] not in key]<EOL>newdtype = np.dtype(keydesc + r1desc + r2desc)<EOL>newrec = np.empty(common_len + left_len + right_len, dtype=newdtype)<EOL>if jointype != '<STR_LIT>' and defaults is not None: <EOL><INDENT>newrec_fields = list(newrec.dtype.fields.keys())<EOL>for k, v in list(defaults.items()):<EOL><INDENT>if k in newrec_fields:<EOL><INDENT>newrec[k] = v<EOL><DEDENT><DEDENT><DEDENT>for field in r1.dtype.names:<EOL><INDENT>newfield = mapped_r1field(field)<EOL>if common_len:<EOL><INDENT>newrec[newfield][:common_len] = r1[field][r1ind]<EOL><DEDENT>if (jointype == "<STR_LIT>" or jointype == "<STR_LIT>") and left_len:<EOL><INDENT>newrec[newfield][common_len:(common_len+left_len)] = r1[field][left_ind]<EOL><DEDENT><DEDENT>for field in r2.dtype.names:<EOL><INDENT>newfield = mapped_r2field(field)<EOL>if field not in key and common_len:<EOL><INDENT>newrec[newfield][:common_len] = r2[field][r2ind]<EOL><DEDENT>if jointype == "<STR_LIT>" and right_len:<EOL><INDENT>newrec[newfield][-right_len:] = r2[field][right_ind]<EOL><DEDENT><DEDENT>newrec.sort(order=key)<EOL>return rec_view(newrec)<EOL>

Join record arrays *r1* and *r2* on *key*; *key* is a tuple of
field names -- if *key* is a string it is assumed to be a single
attribute name. If *r1* and *r2* have equal values on all the keys
in the *key* tuple, then their fields will be merged into a new
record array containing the intersection of the fields of *r1* and
*r2*.

*r1* (also *r2*) must not have any duplicate keys.

The *jointype* keyword can be 'inner', 'outer', 'leftouter'.  To
do a rightouter join just reverse *r1* and *r2*.

The *defaults* keyword is a dictionary filled with
``{column_name:default_value}`` pairs.

The keywords *r1postfix* and *r2postfix* are postfixed to column names
(other than keys) that are both in *r1* and *r2*.


def csv2rec(fname, comments='<STR_LIT:#>', skiprows=<NUM_LIT:0>, checkrows=<NUM_LIT:0>, delimiter='<STR_LIT:U+002C>',<EOL>converterd=None, names=None, missing='<STR_LIT>', missingd=None,<EOL>use_mrecords=True):

if converterd is None:<EOL><INDENT>converterd = dict()<EOL><DEDENT>if missingd is None:<EOL><INDENT>missingd = {}<EOL><DEDENT>import dateutil.parser<EOL>import datetime<EOL>parsedate = dateutil.parser.parse<EOL>fh = cbook.to_filehandle(fname)<EOL>class FH:<EOL><INDENT>"""<STR_LIT>"""<EOL>def __init__(self, fh):<EOL><INDENT>self.fh = fh<EOL><DEDENT>def close(self):<EOL><INDENT>self.fh.close()<EOL><DEDENT>def seek(self, arg):<EOL><INDENT>self.fh.seek(arg)<EOL><DEDENT>def fix(self, s):<EOL><INDENT>return '<STR_LIT:U+0020>'.join(s.split())<EOL><DEDENT>def __next__(self):<EOL><INDENT>return self.fix(next(self.fh))<EOL><DEDENT>def __iter__(self):<EOL><INDENT>for line in self.fh:<EOL><INDENT>yield self.fix(line)<EOL><DEDENT><DEDENT><DEDENT>if delimiter=='<STR_LIT:U+0020>':<EOL><INDENT>fh = FH(fh)<EOL><DEDENT>reader = csv.reader(fh, delimiter=delimiter)<EOL>def process_skiprows(reader):<EOL><INDENT>if skiprows:<EOL><INDENT>for i, row in enumerate(reader):<EOL><INDENT>if i>=(skiprows-<NUM_LIT:1>): break<EOL><DEDENT><DEDENT>return fh, reader<EOL><DEDENT>process_skiprows(reader)<EOL>def ismissing(name, val):<EOL><INDENT>"<STR_LIT>"<EOL>if val == missing or val == missingd.get(name) or val == '<STR_LIT>':<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>def with_default_value(func, default):<EOL><INDENT>def newfunc(name, val):<EOL><INDENT>if ismissing(name, val):<EOL><INDENT>return default<EOL><DEDENT>else:<EOL><INDENT>return func(val)<EOL><DEDENT><DEDENT>return newfunc<EOL><DEDENT>def mybool(x):<EOL><INDENT>if x=='<STR_LIT:True>': return True<EOL>elif x=='<STR_LIT:False>': return False<EOL>else: raise ValueError('<STR_LIT>')<EOL><DEDENT>dateparser = dateutil.parser.parse<EOL>mydateparser = with_default_value(dateparser, datetime.date(<NUM_LIT:1>,<NUM_LIT:1>,<NUM_LIT:1>))<EOL>myfloat = with_default_value(float, np.nan)<EOL>myint = with_default_value(int, -<NUM_LIT:1>)<EOL>mystr = with_default_value(str, '<STR_LIT>')<EOL>mybool = with_default_value(mybool, None)<EOL>def mydate(x):<EOL><INDENT>d = dateparser(x)<EOL>if d.hour><NUM_LIT:0> or d.minute><NUM_LIT:0> or d.second><NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return d.date()<EOL><DEDENT>mydate = with_default_value(mydate, datetime.date(<NUM_LIT:1>,<NUM_LIT:1>,<NUM_LIT:1>))<EOL>def get_func(name, item, func):<EOL><INDENT>funcmap = {mybool:myint,myint:myfloat, myfloat:mydate, mydate:mydateparser, mydateparser:mystr}<EOL>try: func(name, item)<EOL>except:<EOL><INDENT>if func==mystr:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>else: return get_func(name, item, funcmap[func])    <EOL><DEDENT>else: return func<EOL><DEDENT>itemd = {<EOL>'<STR_LIT>' : '<STR_LIT>',<EOL>'<STR_LIT:file>' : '<STR_LIT>',<EOL>'<STR_LIT>' : '<STR_LIT>',<EOL>}<EOL>def get_converters(reader):<EOL><INDENT>converters = None<EOL>for i, row in enumerate(reader):<EOL><INDENT>if i==<NUM_LIT:0>:<EOL><INDENT>converters = [mybool]*len(row)<EOL><DEDENT>if checkrows and i>checkrows:<EOL><INDENT>break<EOL><DEDENT>for j, (name, item) in enumerate(zip(names, row)):<EOL><INDENT>func = converterd.get(j)<EOL>if func is None:<EOL><INDENT>func = converterd.get(name)<EOL><DEDENT>if func is None:<EOL><INDENT>func = converters[j]<EOL>if len(item.strip()):<EOL><INDENT>func = get_func(name, item, func)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>func = with_default_value(func, None)<EOL><DEDENT>converters[j] = func<EOL><DEDENT><DEDENT>return converters<EOL><DEDENT>needheader = names is None<EOL>if needheader:<EOL><INDENT>for row in reader:<EOL><INDENT>if len(row) and row[<NUM_LIT:0>].startswith(comments):<EOL><INDENT>continue<EOL><DEDENT>headers = row<EOL>break<EOL><DEDENT>delete = set("""<STR_LIT>""")<EOL>delete.add('<STR_LIT:">')<EOL>names = []<EOL>seen = dict()<EOL>for i, item in enumerate(headers):<EOL><INDENT>item = item.strip().lower().replace('<STR_LIT:U+0020>', '<STR_LIT:_>')<EOL>item = '<STR_LIT>'.join([c for c in item if c not in delete])<EOL>if not len(item):<EOL><INDENT>item = '<STR_LIT>'%i<EOL><DEDENT>item = itemd.get(item, item)<EOL>cnt = seen.get(item, <NUM_LIT:0>)<EOL>if cnt><NUM_LIT:0>:<EOL><INDENT>names.append(item + '<STR_LIT>'%cnt)<EOL><DEDENT>else:<EOL><INDENT>names.append(item)<EOL><DEDENT>seen[item] = cnt+<NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>if cbook.is_string_like(names):<EOL><INDENT>names = [n.strip() for n in names.split('<STR_LIT:U+002C>')]<EOL><DEDENT><DEDENT>converters = get_converters(reader)<EOL>if converters is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>fh.seek(<NUM_LIT:0>)<EOL>reader = csv.reader(fh, delimiter=delimiter)<EOL>process_skiprows(reader)<EOL>if needheader:<EOL><INDENT>skipheader = next(reader)<EOL><DEDENT>rows = []<EOL>rowmasks = []<EOL>for i, row in enumerate(reader):<EOL><INDENT>if not len(row): continue<EOL>if row[<NUM_LIT:0>].startswith(comments): continue<EOL>rows.append([func(name, val) for func, name, val in zip(converters, names, row)])<EOL>rowmasks.append([ismissing(name, val) for name, val in zip(names, row)])<EOL><DEDENT>fh.close()<EOL>if not len(rows):<EOL><INDENT>return None<EOL><DEDENT>if use_mrecords and np.any(rowmasks):<EOL><INDENT>try: from numpy.ma import mrecords<EOL>except ImportError:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>r = mrecords.fromrecords(rows, names=names, mask=rowmasks)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>r = np.rec.fromrecords(rows, names=names)<EOL><DEDENT>return r<EOL>

Load data from comma/space/tab delimited file in *fname* into a
numpy record array and return the record array.

If *names* is *None*, a header row is required to automatically
assign the recarray names.  The headers will be lower cased,
spaces will be converted to underscores, and illegal attribute
name characters removed.  If *names* is not *None*, it is a
sequence of names to use for the column names.  In this case, it
is assumed there is no header row.

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

- *comments*: the character used to indicate the start of a comment
  in the file

- *skiprows*: is the number of rows from the top to skip

- *checkrows*: is the number of rows to check to validate the column
  data type.  When set to zero all rows are validated.

- *converted*: if not *None*, is a dictionary mapping column number or
  munged column name to a converter function.

- *names*: if not None, is a list of header names.  In this case, no
  header will be read from the file

- *missingd* is a dictionary mapping munged column names to field values
  which signify that the field does not contain actual data and should
  be masked, e.g. '0000-00-00' or 'unused'

- *missing*: a string whose value signals a missing field regardless of
  the column it appears in

- *use_mrecords*: if True, return an mrecords.fromrecords record array if any of the data are missing

  If no rows are found, *None* is returned -- see :file:`examples/loadrec.py`


if formatd is None:<EOL><INDENT>formatd = dict()<EOL><DEDENT>for i, name in enumerate(r.dtype.names):<EOL><INDENT>dt = r.dtype[name]<EOL>format = formatd.get(name)<EOL>if format is None:<EOL><INDENT>format = defaultformatd.get(dt.type, FormatObj())<EOL><DEDENT>formatd[name] = format<EOL><DEDENT>return formatd<EOL>

build a formatd guaranteed to have a key for every dtype name


def rec2txt(r, header=None, padding=<NUM_LIT:3>, precision=<NUM_LIT:3>):

if cbook.is_numlike(precision):<EOL><INDENT>precision = [precision]*len(r.dtype)<EOL><DEDENT>def get_type(item,atype=int):<EOL><INDENT>tdict = {None:int, int:float, float:str}<EOL>try: atype(str(item))<EOL>except: return get_type(item,tdict[atype])<EOL>return atype<EOL><DEDENT>def get_justify(colname, column, precision):<EOL><INDENT>ntype = type(column[<NUM_LIT:0>])<EOL>if ntype==np.str or ntype==np.str_ or ntype==np.string0 or ntype==np.string_:<EOL><INDENT>length = max(len(colname),column.itemsize)<EOL>return <NUM_LIT:0>, length+padding, "<STR_LIT:%s>" <EOL><DEDENT>if ntype==np.int or ntype==np.int16 or ntype==np.int32 or ntype==np.int64 or ntype==np.int8 or ntype==np.int_:<EOL><INDENT>length = max(len(colname),np.max(list(map(len,list(map(str,column))))))<EOL>return <NUM_LIT:1>, length+padding, "<STR_LIT>" <EOL><DEDENT>"""<STR_LIT>"""<EOL>if ntype==np.float or ntype==np.float32 or ntype==np.float64 or (hasattr(np, '<STR_LIT>') and (ntype==np.float96)) or ntype==np.float_:<EOL><INDENT>fmt = "<STR_LIT>" + str(precision) + "<STR_LIT:f>"<EOL>length = max(len(colname),np.max(list(map(len,[fmt%x for x in column]))))<EOL>return <NUM_LIT:1>, length+padding, fmt   <EOL><DEDENT>return <NUM_LIT:0>, max(len(colname),np.max(list(map(len,list(map(str,column))))))+padding, "<STR_LIT:%s>"<EOL><DEDENT>if header is None:<EOL><INDENT>header = r.dtype.names<EOL><DEDENT>justify_pad_prec = [get_justify(header[i],r.__getitem__(colname),precision[i]) for i, colname in enumerate(r.dtype.names)]<EOL>justify_pad_prec_spacer = []<EOL>for i in range(len(justify_pad_prec)):<EOL><INDENT>just,pad,prec = justify_pad_prec[i]<EOL>if i == <NUM_LIT:0>:<EOL><INDENT>justify_pad_prec_spacer.append((just,pad,prec,<NUM_LIT:0>))<EOL><DEDENT>else:<EOL><INDENT>pjust,ppad,pprec = justify_pad_prec[i-<NUM_LIT:1>]<EOL>if pjust == <NUM_LIT:0> and just == <NUM_LIT:1>:<EOL><INDENT>justify_pad_prec_spacer.append((just,pad-padding,prec,<NUM_LIT:0>))<EOL><DEDENT>elif pjust == <NUM_LIT:1> and just == <NUM_LIT:0>:<EOL><INDENT>justify_pad_prec_spacer.append((just,pad,prec,padding))<EOL><DEDENT>else:<EOL><INDENT>justify_pad_prec_spacer.append((just,pad,prec,<NUM_LIT:0>))<EOL><DEDENT><DEDENT><DEDENT>def format(item, just_pad_prec_spacer):<EOL><INDENT>just, pad, prec, spacer = just_pad_prec_spacer<EOL>if just == <NUM_LIT:0>:<EOL><INDENT>return spacer*'<STR_LIT:U+0020>' + str(item).ljust(pad)<EOL><DEDENT>else:<EOL><INDENT>if get_type(item) == float:<EOL><INDENT>item = (prec%float(item))<EOL><DEDENT>elif get_type(item) == int:<EOL><INDENT>item = (prec%int(item))<EOL><DEDENT>return item.rjust(pad)<EOL><DEDENT><DEDENT>textl = []<EOL>textl.append('<STR_LIT>'.join([format(colitem,justify_pad_prec_spacer[j]) for j, colitem in enumerate(header)]))<EOL>for i, row in enumerate(r):<EOL><INDENT>textl.append('<STR_LIT>'.join([format(colitem,justify_pad_prec_spacer[j]) for j, colitem in enumerate(row)]))<EOL>if i==<NUM_LIT:0>:<EOL><INDENT>textl[<NUM_LIT:0>] = textl[<NUM_LIT:0>].rstrip()<EOL><DEDENT><DEDENT>text = os.linesep.join(textl)<EOL>return text<EOL>

Returns a textual representation of a record array.

*r*: numpy recarray

*header*: list of column headers

*padding*: space between each column

*precision*: number of decimal places to use for floats.
    Set to an integer to apply to all floats.  Set to a
    list of integers to apply precision individually.
    Precision for non-floats is simply ignored.

Example::

  precision=[0,2,3]

Output::

  ID    Price   Return
  ABC   12.54    0.234
  XYZ    6.32   -0.076


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.


try:<EOL><INDENT>from mpl_toolkits.natgrid import _natgrid, __version__<EOL>_use_natgrid = True<EOL><DEDENT>except ImportError:<EOL><INDENT>import matplotlib.delaunay as delaunay<EOL>from matplotlib.delaunay import  __version__<EOL>_use_natgrid = False<EOL><DEDENT>if not griddata._reported:<EOL><INDENT>if _use_natgrid:<EOL><INDENT>verbose.report('<STR_LIT>' % __version__)<EOL><DEDENT>else:<EOL><INDENT>verbose.report('<STR_LIT>' % __version__)<EOL><DEDENT>griddata._reported = True<EOL><DEDENT>if xi.ndim != yi.ndim:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if xi.ndim != <NUM_LIT:1> and xi.ndim != <NUM_LIT:2>:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if not len(x)==len(y)==len(z):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if hasattr(z,'<STR_LIT>'):<EOL><INDENT>x = x.compress(z.mask == False)<EOL>y = y.compress(z.mask == False)<EOL>z = z.compressed()<EOL><DEDENT>if _use_natgrid: <EOL><INDENT>if xi.ndim == <NUM_LIT:2>:<EOL><INDENT>xi = xi[<NUM_LIT:0>,:]<EOL>yi = yi[:,<NUM_LIT:0>]<EOL><DEDENT>_natgrid.seti('<STR_LIT>',<NUM_LIT:0>)<EOL>_natgrid.setr('<STR_LIT>',np.nan)<EOL>x = x.astype(np.float)<EOL>y = y.astype(np.float)<EOL>z = z.astype(np.float)<EOL>xo = xi.astype(np.float)<EOL>yo = yi.astype(np.float)<EOL>if min(xo[<NUM_LIT:1>:]-xo[<NUM_LIT:0>:-<NUM_LIT:1>]) < <NUM_LIT:0> or min(yo[<NUM_LIT:1>:]-yo[<NUM_LIT:0>:-<NUM_LIT:1>]) < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>zo = np.empty((yo.shape[<NUM_LIT:0>],xo.shape[<NUM_LIT:0>]), np.float)<EOL>_natgrid.natgridd(x,y,z,xo,yo,zo)<EOL><DEDENT>else: <EOL><INDENT>if xi.ndim != yi.ndim:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if xi.ndim != <NUM_LIT:1> and xi.ndim != <NUM_LIT:2>:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if xi.ndim == <NUM_LIT:1>:<EOL><INDENT>xi,yi = np.meshgrid(xi,yi)<EOL><DEDENT>tri = delaunay.Triangulation(x,y)<EOL>interp = tri.nn_interpolator(z)<EOL>zo = interp(xi,yi)<EOL><DEDENT>if np.any(np.isnan(zo)):<EOL><INDENT>zo = np.ma.masked_where(np.isnan(zo),zo)<EOL><DEDENT>return zo<EOL>

``zi = griddata(x,y,z,xi,yi)`` fits a surface of the form *z* =
*f*(*x*, *y*) to the data in the (usually) nonuniformly spaced
vectors (*x*, *y*, *z*).  :func:`griddata` interpolates this
surface at the points specified by (*xi*, *yi*) to produce
*zi*. *xi* and *yi* must describe a regular grid, can be either 1D
or 2D, but must be monotonically increasing.

A masked array is returned if any grid points are outside convex
hull defined by input data (no extrapolation is done).

Uses natural neighbor interpolation based on Delaunay
triangulation.  By default, this algorithm is provided by the
:mod:`matplotlib.delaunay` package, written by Robert Kern.  The
triangulation algorithm in this package is known to fail on some
nearly pathological cases. For this reason, a separate toolkit
(:mod:`mpl_tookits.natgrid`) has been created that provides a more
robust algorithm fof triangulation and interpolation.  This
toolkit is based on the NCAR natgrid library, which contains code
that is not redistributable under a BSD-compatible license.  When
installed, this function will use the :mod:`mpl_toolkits.natgrid`
algorithm, otherwise it will use the built-in
:mod:`matplotlib.delaunay` package.

The natgrid matplotlib toolkit can be downloaded from
http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792


def less_simple_linear_interpolation( x, y, xi, extrap=False ):

if cbook.is_scalar(xi): xi = [xi]<EOL>x = np.asarray(x)<EOL>y = np.asarray(y)<EOL>xi = np.asarray(xi)<EOL>s = list(y.shape)<EOL>s[<NUM_LIT:0>] = len(xi)<EOL>yi = np.tile( np.nan, s )<EOL>for ii,xx in enumerate(xi):<EOL><INDENT>bb = x == xx<EOL>if np.any(bb):<EOL><INDENT>jj, = np.nonzero(bb)<EOL>yi[ii] = y[jj[<NUM_LIT:0>]]<EOL><DEDENT>elif xx<x[<NUM_LIT:0>]:<EOL><INDENT>if extrap:<EOL><INDENT>yi[ii] = y[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>elif xx>x[-<NUM_LIT:1>]:<EOL><INDENT>if extrap:<EOL><INDENT>yi[ii] = y[-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>jj, = np.nonzero(x<xx)<EOL>jj = max(jj)<EOL>yi[ii] = y[jj] + (xx-x[jj])/(x[jj+<NUM_LIT:1>]-x[jj]) * (y[jj+<NUM_LIT:1>]-y[jj])<EOL><DEDENT><DEDENT>return yi<EOL>

This function provides simple (but somewhat less so than
:func:`cbook.simple_linear_interpolation`) linear interpolation.
:func:`simple_linear_interpolation` will give a list of point
between a start and an end, while this does true linear
interpolation at an arbitrary set of points.

This is very inefficient linear interpolation meant to be used
only for a small number of points in relatively non-intensive use
cases.  For real linear interpolation, use scipy.


<EOL>x=np.asarray(x, np.float_)<EOL>y=np.asarray(y, np.float_)<EOL>yp=np.zeros(y.shape, np.float_)<EOL>dx=x[<NUM_LIT:1>:] - x[:-<NUM_LIT:1>]<EOL>dy=y[<NUM_LIT:1>:] - y[:-<NUM_LIT:1>]<EOL>dydx = dy/dx<EOL>yp[<NUM_LIT:1>:-<NUM_LIT:1>] = (dydx[:-<NUM_LIT:1>] * dx[<NUM_LIT:1>:] + dydx[<NUM_LIT:1>:] * dx[:-<NUM_LIT:1>])/(dx[<NUM_LIT:1>:] + dx[:-<NUM_LIT:1>])<EOL>yp[<NUM_LIT:0>] = <NUM_LIT> * dy[<NUM_LIT:0>]/dx[<NUM_LIT:0>] - yp[<NUM_LIT:1>]<EOL>yp[-<NUM_LIT:1>] = <NUM_LIT> * dy[-<NUM_LIT:1>]/dx[-<NUM_LIT:1>] - yp[-<NUM_LIT:2>]<EOL>return yp<EOL>

:func:`slopes` calculates the slope *y*'(*x*)

The slope is estimated using the slope obtained from that of a
parabola through any three consecutive points.

This method should be superior to that described in the appendix
of A CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russel
W. Stineman (Creative Computing July 1980) in at least one aspect:

  Circles for interpolation demand a known aspect ratio between
  *x*- and *y*-values.  For many functions, however, the abscissa
  are given in different dimensions, so an aspect ratio is
  completely arbitrary.

The parabola method gives very similar results to the circle
method for most regular cases but behaves much better in special
cases.

Norbert Nemec, Institute of Theoretical Physics, University or
Regensburg, April 2006 Norbert.Nemec at physik.uni-regensburg.de

(inspired by a original implementation by Halldor Bjornsson,
Icelandic Meteorological Office, March 2006 halldor at vedur.is)


<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


res, =  np.nonzero(nxutils.points_inside_poly(points, verts))<EOL>return res<EOL>

*points* is a sequence of *x*, *y* points.
*verts* is a sequence of *x*, *y* vertices of a polygon.

Return value is a sequence of indices into points for the points
that are inside the polygon.


if ma.isMaskedArray(xs) or ma.isMaskedArray(ys):<EOL><INDENT>nx = ma<EOL><DEDENT>else:<EOL><INDENT>nx = np<EOL><DEDENT>xs = nx.asarray(xs)<EOL>ys = nx.asarray(ys)<EOL>Nx = len(xs)<EOL>Ny = len(ys)<EOL>assert(Nx==Ny)<EOL>x = xmin*nx.ones(<NUM_LIT:2>*Nx)<EOL>y = nx.ones(<NUM_LIT:2>*Nx)<EOL>x[:Nx] = xs<EOL>y[:Nx] = ys<EOL>y[Nx:] = ys[::-<NUM_LIT:1>]<EOL>return x, y<EOL>

Given a sequence of *xs* and *ys*, return the vertices of a
polygon that has a horizontal base at *xmin* and an upper bound at
the *ys*.  *xmin* is a scalar.

Intended for use with :meth:`matplotlib.axes.Axes.fill`, eg::

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


if ma.isMaskedArray(ylower) or ma.isMaskedArray(yupper) or ma.isMaskedArray(x):<EOL><INDENT>nx = ma<EOL><DEDENT>else:<EOL><INDENT>nx = np<EOL><DEDENT>Nx = len(x)<EOL>if not cbook.iterable(ylower):<EOL><INDENT>ylower = ylower*nx.ones(Nx)<EOL><DEDENT>if not cbook.iterable(yupper):<EOL><INDENT>yupper = yupper*nx.ones(Nx)<EOL><DEDENT>x = nx.concatenate( (x, x[::-<NUM_LIT:1>]) )<EOL>y = nx.concatenate( (yupper, ylower[::-<NUM_LIT:1>]) )<EOL>return x,y<EOL>

Given a sequence of *x*, *ylower* and *yupper*, return the polygon
that fills the regions between them.  *ylower* or *yupper* can be
scalar or iterable.  If they are iterable, they must be equal in
length to *x*.

Return value is *x*, *y* arrays for use with
:meth:`matplotlib.axes.Axes.fill`.


return np.all(X[<NUM_LIT:0>] == X[-<NUM_LIT:1>])<EOL>

Tests whether first and last object in a sequence are the same.  These are
presumably coordinates on a polygonal curve, in which case this function
tests if that curve is closed.


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


def vector_lengths( X, P=<NUM_LIT>, axis=None ):

X = np.asarray(X)<EOL>return (np.sum(X**(P),axis=axis))**(<NUM_LIT:1.>/P)<EOL>

Finds the length of a set of vectors in *n* dimensions.  This is
like the :func:`numpy.norm` function for vectors, but has the ability to
work over a particular axis of the supplied array or matrix.

Computes ``(sum((x_i)^P))^(1/P)`` for each ``{x_i}`` being the
elements of *X* along the given axis.  If *axis* is *None*,
compute over all elements of *X*.


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.


X = distances_along_curve(X)<EOL>return np.concatenate( (np.zeros(<NUM_LIT:1>), np.cumsum(X)) )<EOL>

Computes the distance travelled along a polygonal curve in *N* dimensions.

Where *X* is an *M* x *N* array or matrix.  Returns an array of
length *M* consisting of the distance along the curve at each point
(i.e., the rows of *X*).


def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y):

<EOL>c1x, c1y = q0x + <NUM_LIT>/<NUM_LIT> * (q1x - q0x), q0y + <NUM_LIT>/<NUM_LIT> * (q1y - q0y)<EOL>c2x, c2y = c1x + <NUM_LIT:1.>/<NUM_LIT> * (q2x - q0x), c1y + <NUM_LIT:1.>/<NUM_LIT> * (q2y - q0y)<EOL>return q0x, q0y, c1x, c1y, c2x, c2y, q2x, q2y<EOL>

Converts a quadratic Bezier curve to a cubic approximation.

The inputs are the *x* and *y* coordinates of the three control
points of a quadratic curve, and the output is a tuple of *x* and
*y* coordinates of the four control points of the cubic curve.


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>


self.callbackd.setdefault(N, []).append(func)<EOL>

Call *func* every time *N* events are passed; *func* signature
is ``func(fifo)``.


if self.dataLim is not None:<EOL><INDENT>xys = ((x,y),)<EOL>self.dataLim.update(xys, -<NUM_LIT:1>) <EOL><DEDENT>ind = self._ind % self._nmax<EOL>self._xs[ind] = x<EOL>self._ys[ind] = y<EOL>for N,funcs in list(self.callbackd.items()):<EOL><INDENT>if (self._ind%N)==<NUM_LIT:0>:<EOL><INDENT>for func in funcs:<EOL><INDENT>func(self)<EOL><DEDENT><DEDENT><DEDENT>self._ind += <NUM_LIT:1><EOL>


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.


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


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.


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.


_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 get_window_extent(self, *args, **kwargs):

return self.bbox<EOL>

get the axes bounding box in display space; *args* and
*kwargs* are empty


self.xaxis = maxis.XAxis(self)<EOL>self.yaxis = maxis.YAxis(self)<EOL>self._update_transScale()<EOL>

move this out of __init__ because non-separable axes don't use it


martist.Artist.set_figure(self, fig)<EOL>self.bbox = mtransforms.TransformedBbox(self._position, fig.transFigure)<EOL>self.dataLim = mtransforms.Bbox.unit()<EOL>self.viewLim = mtransforms.Bbox.unit()<EOL>self.transScale = mtransforms.TransformWrapper(<EOL>mtransforms.IdentityTransform())<EOL>self._set_lim_and_transforms()<EOL>

Set the class:`~matplotlib.axes.Axes` figure

accepts a class:`~matplotlib.figure.Figure` instance


self.transAxes = mtransforms.BboxTransformTo(self.bbox)<EOL>self.transScale = mtransforms.TransformWrapper(<EOL>mtransforms.IdentityTransform())<EOL>self.transLimits = mtransforms.BboxTransformFrom(<EOL>mtransforms.TransformedBbox(self.viewLim, self.transScale))<EOL>self.transData = self.transScale + (self.transLimits + self.transAxes)<EOL>self._xaxis_transform = mtransforms.blended_transform_factory(<EOL>self.axes.transData, self.axes.transAxes)<EOL>self._yaxis_transform = mtransforms.blended_transform_factory(<EOL>self.axes.transAxes, self.axes.transData)<EOL>

set the *dataLim* and *viewLim*
:class:`~matplotlib.transforms.Bbox` attributes and the
*transScale*, *transData*, *transLimits* and *transAxes*
transformations.


return self._xaxis_transform<EOL>

Get the transformation used for drawing x-axis labels, ticks
and gridlines.  The x-direction is in data coordinates and the
y-direction is in axis coordinates.

.. 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.


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

Get the transformation used for drawing 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.


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.


return self._yaxis_transform<EOL>

Get the transformation used for drawing y-axis labels, ticks
and gridlines.  The x-direction is in axis coordinates and the
y-direction is in data coordinates.

.. 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.


return (self._yaxis_transform +<EOL>mtransforms.ScaledTranslation(-<NUM_LIT:1> * pad_points / <NUM_LIT>, <NUM_LIT:0>,<EOL>self.figure.dpi_scale_trans),<EOL>"<STR_LIT>", "<STR_LIT:right>")<EOL>

Get the transformation used for drawing y-axis labels, which
will add the given amount of padding (in points) between the
axes and the label.  The x-direction is in axis coordinates
and the y-direction is in data 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.


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

Get the transformation used for drawing the secondary y-axis
labels, which will add the given amount of padding (in points)
between the axes and the label.  The x-direction is in axis
coordinates and the y-direction is in data 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.


if original:<EOL><INDENT>return self._originalPosition.frozen()<EOL><DEDENT>else:<EOL><INDENT>return self._position.frozen()<EOL><DEDENT>

Return the a copy of the axes rectangle as a Bbox


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
    ==========   ====================


pos = self.get_position(original=True)<EOL>self.set_position(pos, which='<STR_LIT>')<EOL>

Make the original position the active position


a.set_figure(self.figure)<EOL>if not a.is_transform_set():<EOL><INDENT>a.set_transform(self.transData)<EOL><DEDENT>a.set_axes(self)<EOL>

set the boilerplate props for artists added to axes


return mpatches.Rectangle((<NUM_LIT:0.0>, <NUM_LIT:0.0>), <NUM_LIT:1.0>, <NUM_LIT:1.0>)<EOL>

Returns the patch used to draw the background of the axes.  It
is also used as the clipping path for any data elements on the
axes.

In the standard axes, this is a rectangle, but in other
projections it may not be.

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


<EOL>self.xaxis.cla()<EOL>self.yaxis.cla()<EOL>self.ignore_existing_data_limits = True<EOL>self.callbacks = cbook.CallbackRegistry(('<STR_LIT>',<EOL>'<STR_LIT>'))<EOL>if self._sharex is not None:<EOL><INDENT>self.xaxis.major = self._sharex.xaxis.major<EOL>self.xaxis.minor = self._sharex.xaxis.minor<EOL>x0, x1 = self._sharex.get_xlim()<EOL>self.set_xlim(x0, x1, emit=False)<EOL>self.xaxis.set_scale(self._sharex.xaxis.get_scale())<EOL><DEDENT>else:<EOL><INDENT>self.xaxis.set_scale('<STR_LIT>')<EOL><DEDENT>if self._sharey is not None:<EOL><INDENT>self.yaxis.major = self._sharey.yaxis.major<EOL>self.yaxis.minor = self._sharey.yaxis.minor<EOL>y0, y1 = self._sharey.get_ylim()<EOL>self.set_ylim(y0, y1, emit=False)<EOL>self.yaxis.set_scale(self._sharey.yaxis.get_scale())<EOL><DEDENT>else:<EOL><INDENT>self.yaxis.set_scale('<STR_LIT>')<EOL><DEDENT>self._autoscaleon = True<EOL>self._update_transScale()         <EOL>self._get_lines = _process_plot_var_args(self)<EOL>self._get_patches_for_fill = _process_plot_var_args(self, '<STR_LIT>')<EOL>self._gridOn = rcParams['<STR_LIT>']<EOL>self.lines = []<EOL>self.patches = []<EOL>self.texts = []<EOL>self.tables = []<EOL>self.artists = []<EOL>self.images = []<EOL>self.legend_ = None<EOL>self.collections = []  <EOL>self.grid(self._gridOn)<EOL>props = font_manager.FontProperties(size=rcParams['<STR_LIT>'])<EOL>self.titleOffsetTrans = mtransforms.ScaledTranslation(<EOL><NUM_LIT:0.0>, <NUM_LIT> / <NUM_LIT>, self.figure.dpi_scale_trans)<EOL>self.title =  mtext.Text(<EOL>x=<NUM_LIT:0.5>, y=<NUM_LIT:1.0>, text='<STR_LIT>',<EOL>fontproperties=props,<EOL>verticalalignment='<STR_LIT>',<EOL>horizontalalignment='<STR_LIT>',<EOL>)<EOL>self.title.set_transform(self.transAxes + self.titleOffsetTrans)<EOL>self.title.set_clip_box(None)<EOL>self._set_artist_props(self.title)<EOL>self.patch = self.axesPatch = self._gen_axes_patch()<EOL>self.patch.set_figure(self.figure)<EOL>self.patch.set_facecolor(self._axisbg)<EOL>self.patch.set_edgecolor('<STR_LIT:None>')<EOL>self.patch.set_linewidth(<NUM_LIT:0>)<EOL>self.patch.set_transform(self.transAxes)<EOL>self.frame = self.axesFrame = self._gen_axes_patch()<EOL>self.frame.set_figure(self.figure)<EOL>self.frame.set_facecolor('<STR_LIT:none>')<EOL>self.frame.set_edgecolor(rcParams['<STR_LIT>'])<EOL>self.frame.set_linewidth(rcParams['<STR_LIT>'])<EOL>self.frame.set_transform(self.transAxes)<EOL>self.frame.set_zorder(<NUM_LIT>)<EOL>self.axison = True<EOL>self.xaxis.set_clip_path(self.patch)<EOL>self.yaxis.set_clip_path(self.patch)<EOL>self._shared_x_axes.clean()<EOL>self._shared_y_axes.clean()<EOL>


self.cla()<EOL>


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.


return self._hold<EOL>


if b is None:<EOL><INDENT>self._hold = not self._hold<EOL><DEDENT>else:<EOL><INDENT>self._hold = b<EOL><DEDENT>

call signature::

  hold(b=None)

Set the hold state.  If *hold* is *None* (default), toggle the
*hold* state.  Else set the *hold* state to boolean value *b*.

Examples:

* toggle hold:
  >>> hold()
* turn hold on:
  >>> hold(True)
* turn hold off
  >>> hold(False)

When hold is True, subsequent plot commands will be added to
the current axes.  When hold is False, the current axes and
figure will be cleared on the next plot command


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>


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>


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
  =====  ============


xmin,xmax = self.get_xbound()<EOL>xsize = max(math.fabs(xmax-xmin), <NUM_LIT>)<EOL>ymin,ymax = self.get_ybound()<EOL>ysize = max(math.fabs(ymax-ymin), <NUM_LIT>)<EOL>return ysize/xsize<EOL>

Returns the aspect ratio of the raw data.

This method is intended to be overridden by new projection
types.


if position is None:<EOL><INDENT>position = self.get_position(original=True)<EOL><DEDENT>aspect = self.get_aspect()<EOL>if aspect == '<STR_LIT>':<EOL><INDENT>self.set_position( position , which='<STR_LIT>')<EOL>return<EOL><DEDENT>if aspect == '<STR_LIT>':<EOL><INDENT>A = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>A = aspect<EOL><DEDENT>if self in self._shared_x_axes or self in self._shared_y_axes:<EOL><INDENT>if self._adjustable == '<STR_LIT>':<EOL><INDENT>self._adjustable = '<STR_LIT>'<EOL>warnings.warn(<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>figW,figH = self.get_figure().get_size_inches()<EOL>fig_aspect = figH/figW<EOL>if self._adjustable == '<STR_LIT>':<EOL><INDENT>box_aspect = A * self.get_data_ratio()<EOL>pb = position.frozen()<EOL>pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect)<EOL>self.set_position(pb1.anchored(self.get_anchor(), pb), '<STR_LIT>')<EOL>return<EOL><DEDENT>self.set_position(position, which='<STR_LIT>')<EOL>xmin,xmax = self.get_xbound()<EOL>xsize = max(math.fabs(xmax-xmin), <NUM_LIT>)<EOL>ymin,ymax = self.get_ybound()<EOL>ysize = max(math.fabs(ymax-ymin), <NUM_LIT>)<EOL>l,b,w,h = position.bounds<EOL>box_aspect = fig_aspect * (h/w)<EOL>data_ratio = box_aspect / A<EOL>y_expander = (data_ratio*xsize/ysize - <NUM_LIT:1.0>)<EOL>if abs(y_expander) < <NUM_LIT>:<EOL><INDENT>return<EOL><DEDENT>dL = self.dataLim<EOL>xr = <NUM_LIT> * dL.width<EOL>yr = <NUM_LIT> * dL.height<EOL>xmarg = xsize - xr<EOL>ymarg = ysize - yr<EOL>Ysize = data_ratio * xsize<EOL>Xsize = ysize / data_ratio<EOL>Xmarg = Xsize - xr<EOL>Ymarg = Ysize - yr<EOL>xm = <NUM_LIT:0>  <EOL>ym = <NUM_LIT:0><EOL>changex = (self in self._shared_y_axes<EOL>and self not in self._shared_x_axes)<EOL>changey = (self in self._shared_x_axes<EOL>and self not in self._shared_y_axes)<EOL>if changex and changey:<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>return<EOL><DEDENT>if changex:<EOL><INDENT>adjust_y = False<EOL><DEDENT>else:<EOL><INDENT>if xmarg > xm and ymarg > ym:<EOL><INDENT>adjy = ((Ymarg > <NUM_LIT:0> and y_expander < <NUM_LIT:0>)<EOL>or (Xmarg < <NUM_LIT:0> and y_expander > <NUM_LIT:0>))<EOL><DEDENT>else:<EOL><INDENT>adjy = y_expander > <NUM_LIT:0><EOL><DEDENT>adjust_y = changey or adjy  <EOL><DEDENT>if adjust_y:<EOL><INDENT>yc = <NUM_LIT:0.5>*(ymin+ymax)<EOL>y0 = yc - Ysize/<NUM_LIT><EOL>y1 = yc + Ysize/<NUM_LIT><EOL>self.set_ybound((y0, y1))<EOL><DEDENT>else:<EOL><INDENT>xc = <NUM_LIT:0.5>*(xmin+xmax)<EOL>x0 = xc - Xsize/<NUM_LIT><EOL>x1 = xc + Xsize/<NUM_LIT><EOL>self.set_xbound((x0, x1))<EOL><DEDENT>

Use :meth:`_aspect` and :meth:`_adjustable` to modify the
axes box or the view limits.


if len(v)==<NUM_LIT:1> and is_string_like(v[<NUM_LIT:0>]):<EOL><INDENT>s = v[<NUM_LIT:0>].lower()<EOL>if s=='<STR_LIT>': self.set_axis_on()<EOL>elif s=='<STR_LIT>': self.set_axis_off()<EOL>elif s in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:image>'):<EOL><INDENT>self.set_autoscale_on(True)<EOL>self.set_aspect('<STR_LIT>')<EOL>self.autoscale_view()<EOL>if s=='<STR_LIT>':<EOL><INDENT>self.set_aspect('<STR_LIT>', adjustable='<STR_LIT>')<EOL><DEDENT>elif s == '<STR_LIT>':<EOL><INDENT>self.set_aspect('<STR_LIT>', adjustable='<STR_LIT>', anchor='<STR_LIT:C>')<EOL>self.set_autoscale_on(False) <EOL><DEDENT>elif s=='<STR_LIT>':<EOL><INDENT>self.autoscale_view(tight=True)<EOL>self.set_autoscale_on(False)<EOL><DEDENT>elif s == '<STR_LIT:image>':<EOL><INDENT>self.autoscale_view(tight=True)<EOL>self.set_autoscale_on(False)<EOL>self.set_aspect('<STR_LIT>', adjustable='<STR_LIT>', anchor='<STR_LIT:C>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % s)<EOL><DEDENT>xmin, xmax = self.get_xlim()<EOL>ymin, ymax = self.get_ylim()<EOL>return xmin, xmax, ymin, ymax<EOL><DEDENT>try: v[<NUM_LIT:0>]<EOL>except IndexError:<EOL><INDENT>emit = kwargs.get('<STR_LIT>', True)<EOL>xmin = kwargs.get('<STR_LIT>', None)<EOL>xmax = kwargs.get('<STR_LIT>', None)<EOL>xmin, xmax = self.set_xlim(xmin, xmax, emit)<EOL>ymin = kwargs.get('<STR_LIT>', None)<EOL>ymax = kwargs.get('<STR_LIT>', None)<EOL>ymin, ymax = self.set_ylim(ymin, ymax, emit)<EOL>return xmin, xmax, ymin, ymax<EOL><DEDENT>v = v[<NUM_LIT:0>]<EOL>if len(v) != <NUM_LIT:4>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>self.set_xlim([v[<NUM_LIT:0>], v[<NUM_LIT:1>]])<EOL>self.set_ylim([v[<NUM_LIT:2>], v[<NUM_LIT:3>]])<EOL>return v<EOL>

Convenience method for manipulating the x and y view limits
and the aspect ratio of the plot.

*kwargs* are passed on to :meth:`set_xlim` and
:meth:`set_ylim`


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

Return a list of artists the axes contains.

.. deprecated:: 0.98


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


return self.legend_<EOL>

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


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

return a list of Axes images contained by the Axes


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

Return a list of lines contained by the Axes


return self.xaxis<EOL>


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

Get the x grid lines as a list of Line2D instances


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

Get the xtick lines as a list of Line2D instances


return self.yaxis<EOL>


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

Get the y grid lines as a list of Line2D instances


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

Get the ytick lines as a list of Line2D instances


return (<EOL>len(self.collections) +<EOL>len(self.images) +<EOL>len(self.lines) +<EOL>len(self.patches))><NUM_LIT:0><EOL>

Return *True* if any artists have been added to axes.

        This should not be used to determine whether the *dataLim*
        need to be updated, and may not actually be useful for
        anything.


a.set_axes(self)<EOL>self.artists.append(a)<EOL>self._set_artist_props(a)<EOL>a.set_clip_path(self.patch)<EOL>a._remove_method = lambda h: self.artists.remove(h)<EOL>

Add any :class:`~matplotlib.artist.Artist` to the axes


def add_collection(self, collection, autolim=True):

label = collection.get_label()<EOL>if not label:<EOL><INDENT>collection.set_label('<STR_LIT>'%len(self.collections))<EOL><DEDENT>self.collections.append(collection)<EOL>self._set_artist_props(collection)<EOL>collection.set_clip_path(self.patch)<EOL>if autolim:<EOL><INDENT>if collection._paths and len(collection._paths):<EOL><INDENT>self.update_datalim(collection.get_datalim(self.transData))<EOL><DEDENT><DEDENT>collection._remove_method = lambda h: self.collections.remove(h)<EOL>

add a :class:`~matplotlib.collections.Collection` instance
to the axes


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


self._set_artist_props(p)<EOL>p.set_clip_path(self.patch)<EOL>self._update_patch_limits(p)<EOL>self.patches.append(p)<EOL>p._remove_method = lambda h: self.patches.remove(h)<EOL>

Add a :class:`~matplotlib.patches.Patch` *p* to the list of
axes patches; the clipbox will be set to the Axes clipping
box.  If the transform is not set, it will be set to
:attr:`transData`.


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


self._set_artist_props(tab)<EOL>self.tables.append(tab)<EOL>tab.set_clip_path(self.patch)<EOL>tab._remove_method = lambda h: self.tables.remove(h)<EOL>

Add a :class:`~matplotlib.tables.Table` instance to the
list of axes tables


<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


def update_datalim(self, xys, updatex=True, updatey=True):

<EOL>if iterable(xys) and not len(xys): return<EOL>if not ma.isMaskedArray(xys):<EOL><INDENT>xys = np.asarray(xys)<EOL><DEDENT>self.dataLim.update_from_data_xy(xys, self.ignore_existing_data_limits,<EOL>updatex=updatex, updatey=updatey)<EOL>self.ignore_existing_data_limits = False<EOL>

Update the data lim bbox with seq of xy tups or equiv. 2-D array


<EOL>if iterable(x) and not len(x): return<EOL>self.dataLim.update_from_data(x, y, self.ignore_existing_data_limits)<EOL>self.ignore_existing_data_limits = False<EOL>

Update the data lim bbox with seq of xy tups


self.dataLim.set(mtransforms.Bbox.union([self.dataLim, bounds]))<EOL>

Update the datalim to include the given
:class:`~matplotlib.transforms.Bbox` *bounds*


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.patch.contains(mouseevent)[<NUM_LIT:0>]<EOL>

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


return self._autoscaleon<EOL>

Get whether autoscaling is applied on plot commands


self._autoscaleon = b<EOL>

Set whether autoscaling is applied on plot commands

accepts: [ *True* | *False* ]


def autoscale_view(self, tight=False, scalex=True, scaley=True):

<EOL>if not self._autoscaleon: return<EOL>if scalex:<EOL><INDENT>xshared = self._shared_x_axes.get_siblings(self)<EOL>dl = [ax.dataLim for ax in xshared]<EOL>bb = mtransforms.BboxBase.union(dl)<EOL>x0, x1 = bb.intervalx<EOL><DEDENT>if scaley:<EOL><INDENT>yshared = self._shared_y_axes.get_siblings(self)<EOL>dl = [ax.dataLim for ax in yshared]<EOL>bb = mtransforms.BboxBase.union(dl)<EOL>y0, y1 = bb.intervaly<EOL><DEDENT>if (tight or (len(self.images)><NUM_LIT:0> and<EOL>len(self.lines)==<NUM_LIT:0> and<EOL>len(self.patches)==<NUM_LIT:0>)):<EOL><INDENT>if scalex:<EOL><INDENT>self.set_xbound(x0, x1)<EOL><DEDENT>if scaley:<EOL><INDENT>self.set_ybound(y0, y1)<EOL><DEDENT>return<EOL><DEDENT>if scalex:<EOL><INDENT>XL = self.xaxis.get_major_locator().view_limits(x0, x1)<EOL>self.set_xbound(XL)<EOL><DEDENT>if scaley:<EOL><INDENT>YL = self.yaxis.get_major_locator().view_limits(y0, y1)<EOL>self.set_ybound(YL)<EOL><DEDENT>

autoscale the view limits using the data limits. You can
selectively autoscale only a single axis, eg, the xaxis by
setting *scaley* to *False*.  The autoscaling preserves any
axis direction reversal that has already been done.


def draw(self, renderer=None, inframe=False):

if renderer is None:<EOL><INDENT>renderer = self._cachedRenderer<EOL><DEDENT>if renderer is None:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>if not self.get_visible(): return<EOL>renderer.open_group('<STR_LIT>')<EOL>self.apply_aspect()<EOL>if self.axison and self._frameon:<EOL><INDENT>self.patch.draw(renderer)<EOL><DEDENT>artists = []<EOL>if len(self.images)<=<NUM_LIT:1> or renderer.option_image_nocomposite():<EOL><INDENT>for im in self.images:<EOL><INDENT>im.draw(renderer)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>mag = renderer.get_image_magnification()<EOL>ims = [(im.make_image(mag),<NUM_LIT:0>,<NUM_LIT:0>)<EOL>for im in self.images if im.get_visible()]<EOL>l, b, r, t = self.bbox.extents<EOL>width = mag*((round(r) + <NUM_LIT:0.5>) - (round(l) - <NUM_LIT:0.5>))<EOL>height = mag*((round(t) + <NUM_LIT:0.5>) - (round(b) - <NUM_LIT:0.5>))<EOL>im = mimage.from_images(height,<EOL>width,<EOL>ims)<EOL>im.is_grayscale = False<EOL>l, b, w, h = self.bbox.bounds<EOL>renderer.draw_image(<EOL>round(l), round(b), im, self.bbox,<EOL>self.patch.get_path(),<EOL>self.patch.get_transform())<EOL><DEDENT>artists.extend(self.collections)<EOL>artists.extend(self.patches)<EOL>artists.extend(self.lines)<EOL>artists.extend(self.texts)<EOL>artists.extend(self.artists)<EOL>if self.axison and not inframe:<EOL><INDENT>if self._axisbelow:<EOL><INDENT>self.xaxis.set_zorder(<NUM_LIT:0.5>)<EOL>self.yaxis.set_zorder(<NUM_LIT:0.5>)<EOL><DEDENT>else:<EOL><INDENT>self.xaxis.set_zorder(<NUM_LIT>)<EOL>self.yaxis.set_zorder(<NUM_LIT>)<EOL><DEDENT>artists.extend([self.xaxis, self.yaxis])<EOL><DEDENT>if not inframe: artists.append(self.title)<EOL>artists.extend(self.tables)<EOL>if self.legend_ is not None:<EOL><INDENT>artists.append(self.legend_)<EOL><DEDENT>if self.axison and self._frameon:<EOL><INDENT>artists.append(self.frame)<EOL><DEDENT>dsu = [ (a.zorder, i, a) for i, a in enumerate(artists)<EOL>if not a.get_animated() ]<EOL>dsu.sort()<EOL>for zorder, i, a in dsu:<EOL><INDENT>a.draw(renderer)<EOL><DEDENT>renderer.close_group('<STR_LIT>')<EOL>self._cachedRenderer = renderer<EOL>

Draw everything (plot lines, axes, labels)


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)


assert self._cachedRenderer is not None<EOL>self.draw(self._cachedRenderer, inframe=True)<EOL>


return self._frameon<EOL>

Get whether the axes rectangle patch is drawn


self._frameon = b<EOL>

Set whether the axes rectangle patch is drawn

ACCEPTS: [ *True* | *False* ]


return self._axisbelow<EOL>


self._axisbelow = b<EOL>

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

ACCEPTS: [ *True* | *False* ]


if len(kwargs): b = True<EOL>self.xaxis.grid(b, **kwargs)<EOL>self.yaxis.grid(b, **kwargs)<EOL>

call signature::

  grid(self, b=None, **kwargs)

Set the axes grids on or off; *b* is a boolean

If *b* is *None* and ``len(kwargs)==0``, toggle the grid state.  If
*kwargs* are supplied, it is assumed that you want a grid and *b*
is thus set to *True*

*kawrgs* are used to set the grid line properties, eg::

  ax.grid(color='r', linestyle='-', linewidth=2)

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

%(Line2D)s


style = kwargs.pop('<STR_LIT>', '<STR_LIT>').lower()<EOL>scilimits = kwargs.pop('<STR_LIT>', None)<EOL>if scilimits is not None:<EOL><INDENT>try:<EOL><INDENT>m, n = scilimits<EOL>m+n+<NUM_LIT:1>  <EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>axis = kwargs.pop('<STR_LIT>', '<STR_LIT>').lower()<EOL>if style[:<NUM_LIT:3>] == '<STR_LIT>':<EOL><INDENT>sb = True<EOL><DEDENT>elif style in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>sb = False<EOL>if style == '<STR_LIT>':<EOL><INDENT>cb = False<EOL><DEDENT>else:<EOL><INDENT>cb = True<EOL>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT><DEDENT>elif style == '<STR_LIT>':<EOL><INDENT>sb = None<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>if sb is not None:<EOL><INDENT>if axis == '<STR_LIT>' or axis == '<STR_LIT:x>':<EOL><INDENT>self.xaxis.major.formatter.set_scientific(sb)<EOL><DEDENT>if axis == '<STR_LIT>' or axis == '<STR_LIT:y>':<EOL><INDENT>self.yaxis.major.formatter.set_scientific(sb)<EOL><DEDENT><DEDENT>if scilimits is not None:<EOL><INDENT>if axis == '<STR_LIT>' or axis == '<STR_LIT:x>':<EOL><INDENT>self.xaxis.major.formatter.set_powerlimits(scilimits)<EOL><DEDENT>if axis == '<STR_LIT>' or axis == '<STR_LIT:y>':<EOL><INDENT>self.yaxis.major.formatter.set_powerlimits(scilimits)<EOL><DEDENT><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>raise AttributeError(<EOL>"<STR_LIT>")<EOL><DEDENT>

Convenience method for manipulating the ScalarFormatter
used by default for linear axes.

Optional keyword arguments:

  ============   =====================================
  Keyword        Description
  ============   =====================================
  *style*        [ 'sci' (or 'scientific') | 'plain' ]
                 plain turns off scientific notation
  *scilimits*    (m, n), pair of integers; if *style*
                 is 'sci', scientific notation will
                 be used for numbers outside the range
                 10`-m`:sup: to 10`n`:sup:.
                 Use (0,0) to include all numbers.
  *axis*         [ 'x' | 'y' | 'both' ]
  ============   =====================================

Only the major ticks are affected.
If the method is called when the
:class:`~matplotlib.ticker.ScalarFormatter` is not the
:class:`~matplotlib.ticker.Formatter` being used, an
:exc:`AttributeError` will be raised.


self.axison = False<EOL>


self.axison = True<EOL>


return self._axisbg<EOL>


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

set the axes background color

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


left, right = self.get_xlim()<EOL>self.set_xlim(right, left)<EOL>


left, right = self.get_xlim()<EOL>return right < left<EOL>


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


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.


return tuple(self.viewLim.intervalx)<EOL>


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


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


return self.xaxis.get_ticklocs(minor=minor)<EOL>

Return the x ticks as a list of locations


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


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

Get the xtick labels as a list of Text instances


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


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


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


left, right = self.get_ylim()<EOL>self.set_ylim(right, left)<EOL>


left, right = self.get_ylim()<EOL>return right < left<EOL>


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


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.


return tuple(self.viewLim.intervaly)<EOL>


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


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

call signature::

  set_yscale(value)

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

ACCEPTS: [%(scale)s]

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


return self.yaxis.get_ticklocs(minor=minor)<EOL>

Return the y ticks as a list of locations


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

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

Set the y ticks with list of *ticks*

ACCEPTS: sequence of floats

Keyword arguments:

  *minor*: [ False | True ]
    Sets the minor ticks if True


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


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


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


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


xmin, xmax = self.dataLim.intervalx<EOL>if xmin==<NUM_LIT:0.>:<EOL><INDENT>dmax = today = datetime.date.today()<EOL>dmin = today-datetime.timedelta(days=<NUM_LIT:10>)<EOL>self._process_unit_info(xdata=(dmin, dmax))<EOL>dmin, dmax = self.convert_xunits([dmin, dmax])<EOL>self.viewLim.intervalx = dmin, dmax<EOL>self.dataLim.intervalx = dmin, dmax<EOL><DEDENT>locator = self.xaxis.get_major_locator()<EOL>if not isinstance(locator, mdates.DateLocator):<EOL><INDENT>locator = mdates.AutoDateLocator(tz)<EOL>self.xaxis.set_major_locator(locator)<EOL><DEDENT>if self.viewLim.intervalx[<NUM_LIT:0>]==<NUM_LIT:0.>:<EOL><INDENT>self.viewLim.intervalx = tuple(self.dataLim.intervalx)<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.xaxis.set_major_formatter(formatter)<EOL><DEDENT>

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

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


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.


try: return self.fmt_xdata(x)<EOL>except TypeError:<EOL><INDENT>func = self.xaxis.get_major_formatter().format_data_short<EOL>val = func(x)<EOL>return val<EOL><DEDENT>

Return *x* string formatted.  This function will use the attribute
self.fmt_xdata if it is callable, else will fall back on the xaxis
major formatter


try: return self.fmt_ydata(y)<EOL>except TypeError:<EOL><INDENT>func = self.yaxis.get_major_formatter().format_data_short<EOL>val =  func(y)<EOL>return val<EOL><DEDENT>

Return y string formatted.  This function will use the
:attr:`fmt_ydata` attribute if it is callable, else will fall
back on the yaxis major formatter


if x is None:<EOL><INDENT>x = '<STR_LIT>'<EOL><DEDENT>if y is None:<EOL><INDENT>y = '<STR_LIT>'<EOL><DEDENT>xs = self.format_xdata(x)<EOL>ys = self.format_ydata(y)<EOL>return  '<STR_LIT>'%(xs,ys)<EOL>

return a format string formatting the *x*, *y* coord


return True<EOL>

Return *True* if this axes support the zoom box


return self._navigate<EOL>

Get whether the axes responds to navigation commands


self._navigate = b<EOL>

Set whether the axes responds to navigation toolbar commands

ACCEPTS: [ True | False ]


return self._navigate_mode<EOL>

Get the navigation toolbar button status: 'PAN', 'ZOOM', or None


self._navigate_mode = b<EOL>

Set the navigation toolbar button status;

.. warning::
    this is not a user-API function.


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.


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.