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

call signatures::

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

Create a pseudocolor plot of a 2-D array.

*C* is the array of color values.

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

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

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

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

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

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

Keyword arguments:

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

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

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

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

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

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

    If 'None', edges will not be visible.

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

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

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

.. _axes-pcolor-grid-orientation:

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

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

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

is equivalent to:

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

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

so if you have::

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

then you need::

  pcolor(X, Y, C.T)

or::

  pcolor(C.T)

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

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

%(PolyCollection)s


if not self._hold: self.cla()<EOL>alpha = kwargs.pop('<STR_LIT>', <NUM_LIT:1.0>)<EOL>norm = kwargs.pop('<STR_LIT>', None)<EOL>cmap = kwargs.pop('<STR_LIT>', None)<EOL>vmin = kwargs.pop('<STR_LIT>', None)<EOL>vmax = kwargs.pop('<STR_LIT>', None)<EOL>shading = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>edgecolors = kwargs.pop('<STR_LIT>', '<STR_LIT:None>')<EOL>antialiased = kwargs.pop('<STR_LIT>', False)<EOL>X, Y, C = self._pcolorargs('<STR_LIT>', *args)<EOL>Ny, Nx = X.shape<EOL>C = ma.ravel(C[<NUM_LIT:0>:Ny-<NUM_LIT:1>, <NUM_LIT:0>:Nx-<NUM_LIT:1>]) <EOL>X = X.ravel()<EOL>Y = Y.ravel()<EOL>coords = np.zeros(((Nx * Ny), <NUM_LIT:2>), dtype=float)<EOL>coords[:, <NUM_LIT:0>] = X<EOL>coords[:, <NUM_LIT:1>] = Y<EOL>if shading == '<STR_LIT>' or edgecolors != '<STR_LIT:None>':<EOL><INDENT>showedges = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>showedges = <NUM_LIT:0><EOL><DEDENT>collection = mcoll.QuadMesh(<EOL>Nx - <NUM_LIT:1>, Ny - <NUM_LIT:1>, coords, showedges,<EOL>antialiased=antialiased)  <EOL>collection.set_alpha(alpha)<EOL>collection.set_array(C)<EOL>if norm is not None: assert(isinstance(norm, mcolors.Normalize))<EOL>if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))<EOL>collection.set_cmap(cmap)<EOL>collection.set_norm(norm)<EOL>if vmin is not None or vmax is not None:<EOL><INDENT>collection.set_clim(vmin, vmax)<EOL><DEDENT>else:<EOL><INDENT>collection.autoscale_None()<EOL><DEDENT>self.grid(False)<EOL>minx = np.amin(X)<EOL>maxx = np.amax(X)<EOL>miny = np.amin(Y)<EOL>maxy = np.amax(Y)<EOL>corners = (minx, miny), (maxx, maxy)<EOL>self.update_datalim( corners)<EOL>self.autoscale_view()<EOL>self.add_collection(collection)<EOL>return collection<EOL>

call signatures::

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

*C* may be a masked array, but *X* and *Y* may not.  Masked
array support is implemented via *cmap* and *norm*; in
contrast, :func:`~matplotlib.pyplot.pcolor` simply does not
draw quadrilaterals with masked colors or vertices.

Keyword arguments:

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

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

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

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

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

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

    If 'None', edges will not be visible.

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

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

Return value is a :class:`matplotlib.collection.QuadMesh`
object.

kwargs can be used to control the
:class:`matplotlib.collections.QuadMesh`
properties:

%(QuadMesh)s

.. seealso::
    :func:`~matplotlib.pyplot.pcolor`:
        For an explanation of the grid orientation and the
        expansion of 1-D *X* and/or *Y* to 2-D arrays.


if not self._hold: self.cla()<EOL>alpha = kwargs.pop('<STR_LIT>', <NUM_LIT:1.0>)<EOL>norm = kwargs.pop('<STR_LIT>', None)<EOL>cmap = kwargs.pop('<STR_LIT>', None)<EOL>vmin = kwargs.pop('<STR_LIT>', None)<EOL>vmax = kwargs.pop('<STR_LIT>', None)<EOL>if norm is not None: assert(isinstance(norm, mcolors.Normalize))<EOL>if cmap is not None: assert(isinstance(cmap, mcolors.Colormap))<EOL>C = args[-<NUM_LIT:1>]<EOL>nr, nc = C.shape<EOL>if len(args) == <NUM_LIT:1>:<EOL><INDENT>style = "<STR_LIT:image>"<EOL>x = [<NUM_LIT:0>, nc]<EOL>y = [<NUM_LIT:0>, nr]<EOL><DEDENT>elif len(args) == <NUM_LIT:3>:<EOL><INDENT>x, y = args[:<NUM_LIT:2>]<EOL>x = np.asarray(x)<EOL>y = np.asarray(y)<EOL>if x.ndim == <NUM_LIT:1> and y.ndim == <NUM_LIT:1>:<EOL><INDENT>if x.size == <NUM_LIT:2> and y.size == <NUM_LIT:2>:<EOL><INDENT>style = "<STR_LIT:image>"<EOL><DEDENT>else:<EOL><INDENT>dx = np.diff(x)<EOL>dy = np.diff(y)<EOL>if (np.ptp(dx) < <NUM_LIT>*np.abs(dx.mean()) and<EOL>np.ptp(dy) < <NUM_LIT>*np.abs(dy.mean())):<EOL><INDENT>style = "<STR_LIT:image>"<EOL><DEDENT>else:<EOL><INDENT>style = "<STR_LIT>"<EOL><DEDENT><DEDENT><DEDENT>elif x.ndim == <NUM_LIT:2> and y.ndim == <NUM_LIT:2>:<EOL><INDENT>style = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if style == "<STR_LIT>":<EOL><INDENT>C = ma.ravel(C) <EOL>X = x.ravel()<EOL>Y = y.ravel()<EOL>Nx = nc+<NUM_LIT:1><EOL>Ny = nr+<NUM_LIT:1><EOL>coords = np.empty(((Nx * Ny), <NUM_LIT:2>), np.float64)<EOL>coords[:, <NUM_LIT:0>] = X<EOL>coords[:, <NUM_LIT:1>] = Y<EOL>collection = mcoll.QuadMesh(nc, nr, coords, <NUM_LIT:0>)<EOL>collection.set_alpha(alpha)<EOL>collection.set_array(C)<EOL>collection.set_cmap(cmap)<EOL>collection.set_norm(norm)<EOL>self.add_collection(collection)<EOL>xl, xr, yb, yt = X.min(), X.max(), Y.min(), Y.max()<EOL>ret = collection<EOL><DEDENT>else:<EOL><INDENT>xl, xr, yb, yt = x[<NUM_LIT:0>], x[-<NUM_LIT:1>], y[<NUM_LIT:0>], y[-<NUM_LIT:1>]<EOL><DEDENT>if style == "<STR_LIT:image>":<EOL><INDENT>im = mimage.AxesImage(self, cmap, norm,<EOL>interpolation='<STR_LIT>',<EOL>origin='<STR_LIT>',<EOL>extent=(xl, xr, yb, yt),<EOL>**kwargs)<EOL>im.set_data(C)<EOL>im.set_alpha(alpha)<EOL>self.images.append(im)<EOL>ret = im<EOL><DEDENT>if style == "<STR_LIT>":<EOL><INDENT>im = mimage.PcolorImage(self, x, y, C,<EOL>cmap=cmap,<EOL>norm=norm,<EOL>alpha=alpha,<EOL>**kwargs)<EOL>self.images.append(im)<EOL>ret = im<EOL><DEDENT>self._set_artist_props(ret)<EOL>if vmin is not None or vmax is not None:<EOL><INDENT>ret.set_clim(vmin, vmax)<EOL><DEDENT>else:<EOL><INDENT>ret.autoscale_None()<EOL><DEDENT>self.update_datalim(np.array([[xl, yb], [xr, yt]]))<EOL>self.autoscale_view(tight=True)<EOL>return ret<EOL>

pseudocolor plot of a 2-D array

Experimental; this is a version of pcolor that
does not draw lines, that provides the fastest
possible rendering with the Agg backend, and that
can handle any quadrilateral grid.

Call signatures::

  pcolor(C, **kwargs)
  pcolor(xr, yr, C, **kwargs)
  pcolor(x, y, C, **kwargs)
  pcolor(X, Y, C, **kwargs)

C is the 2D array of color values corresponding to quadrilateral
cells. Let (nr, nc) be its shape.  C may be a masked array.

``pcolor(C, **kwargs)`` is equivalent to
``pcolor([0,nc], [0,nr], C, **kwargs)``

*xr*, *yr* specify the ranges of *x* and *y* corresponding to the
rectangular region bounding *C*.  If::

    xr = [x0, x1]

and::

    yr = [y0,y1]

then *x* goes from *x0* to *x1* as the second index of *C* goes
from 0 to *nc*, etc.  (*x0*, *y0*) is the outermost corner of
cell (0,0), and (*x1*, *y1*) is the outermost corner of cell
(*nr*-1, *nc*-1).  All cells are rectangles of the same size.
This is the fastest version.

*x*, *y* are 1D arrays of length *nc* +1 and *nr* +1, respectively,
giving the x and y boundaries of the cells.  Hence the cells are
rectangular but the grid may be nonuniform.  The speed is
intermediate.  (The grid is checked, and if found to be
uniform the fast version is used.)

*X* and *Y* are 2D arrays with shape (*nr* +1, *nc* +1) that specify
the (x,y) coordinates of the corners of the colored
quadrilaterals; the quadrilateral for C[i,j] has corners at
(X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]),
(X[i+1,j+1],Y[i+1,j+1]).  The cells need not be rectangular.
This is the most general, but the slowest to render.  It may
produce faster and more compact output using ps, pdf, and
svg backends, however.

Note that the the column index corresponds to the x-coordinate,
and the row index corresponds to y; for details, see
the "Grid Orientation" section below.

Optional keyword arguments:

  *cmap*: [ None | Colormap ]
    A cm Colormap instance from cm. If None, use rc settings.
  *norm*: [ None | Normalize ]
    An mcolors.Normalize instance is used to scale luminance data to
    0,1. If None, defaults to normalize()
  *vmin*/*vmax*: [ None | scalar ]
    *vmin* and *vmax* are used in conjunction with norm to normalize
    luminance data.  If either are *None*, the min and max of the color
    array *C* is used.  If you pass a norm instance, *vmin* and *vmax*
    will be *None*.
  *alpha*: 0 <= scalar <= 1
    the alpha blending value

Return value is an image if a regular or rectangular grid
is specified, and a QuadMesh collection in the general
quadrilateral case.


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

call signature::

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

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

Thanks to John Gill for providing the class and table.

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

%(Table)s


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

call signature::

  ax = twinx()

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


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

call signature::

  ax = twiny()

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


return self._shared_x_axes<EOL>

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


return self._shared_y_axes<EOL>

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


def hist(self, x, bins=<NUM_LIT:10>, range=None, normed=False, cumulative=False,<EOL>bottom=None, histtype='<STR_LIT:bar>', align='<STR_LIT>',<EOL>orientation='<STR_LIT>', rwidth=None, log=False, **kwargs):

if not self._hold: self.cla()<EOL>if kwargs.get('<STR_LIT:width>') is not None:<EOL><INDENT>raise DeprecationWarning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>x = np.transpose(np.array(x))<EOL>if len(x.shape)==<NUM_LIT:1>:<EOL><INDENT>x.shape = (<NUM_LIT:1>,x.shape[<NUM_LIT:0>])<EOL><DEDENT>elif len(x.shape)==<NUM_LIT:2> and x.shape[<NUM_LIT:1>]<x.shape[<NUM_LIT:0>]:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>if iterable(x[<NUM_LIT:0>]) and not is_string_like(x[<NUM_LIT:0>]):<EOL><INDENT>tx = []<EOL>for i in range(len(x)):<EOL><INDENT>tx.append( np.array(x[i]) )<EOL><DEDENT>x = tx<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>binsgiven = (cbook.iterable(bins) or range != None)<EOL>if np.__version__ < "<STR_LIT>": <EOL><INDENT>hist_kwargs = dict(range=range,<EOL>normed=bool(normed), new=True)<EOL><DEDENT>else: <EOL><INDENT>hist_kwargs = dict(range=range,<EOL>normed=bool(normed))<EOL><DEDENT>n = []<EOL>for i in range(len(x)):<EOL><INDENT>m, bins = np.histogram(x[i], bins, **hist_kwargs)<EOL>n.append(m)<EOL><DEDENT>if cumulative:<EOL><INDENT>slc = slice(None)<EOL>if cbook.is_numlike(cumulative) and cumulative < <NUM_LIT:0>:<EOL><INDENT>slc = slice(None,None,-<NUM_LIT:1>)<EOL><DEDENT>if normed:<EOL><INDENT>n = [(m * np.diff(bins))[slc].cumsum()[slc] for m in n]<EOL><DEDENT>else:<EOL><INDENT>n = [m[slc].cumsum()[slc] for m in n]<EOL><DEDENT><DEDENT>patches = []<EOL>if histtype.startswith('<STR_LIT:bar>'):<EOL><INDENT>totwidth = np.diff(bins)<EOL>stacked = False<EOL>if rwidth is not None: dr = min(<NUM_LIT:1.>, max(<NUM_LIT:0.>, rwidth))<EOL>elif len(n)><NUM_LIT:1>: dr = <NUM_LIT><EOL>else: dr = <NUM_LIT:1.0><EOL>if histtype=='<STR_LIT:bar>':<EOL><INDENT>width = dr*totwidth/len(n)<EOL>dw = width<EOL>if len(n)><NUM_LIT:1>:<EOL><INDENT>boffset = -<NUM_LIT:0.5>*dr*totwidth*(<NUM_LIT:1.>-<NUM_LIT:1.>/len(n))<EOL><DEDENT>else:<EOL><INDENT>boffset = <NUM_LIT:0.0><EOL><DEDENT><DEDENT>elif histtype=='<STR_LIT>':<EOL><INDENT>width = dr*totwidth<EOL>boffset, dw = <NUM_LIT:0.0>, <NUM_LIT:0.0><EOL>stacked = True<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % histtype)<EOL><DEDENT>if align == '<STR_LIT>' or align == '<STR_LIT>':<EOL><INDENT>boffset += <NUM_LIT:0.5>*totwidth<EOL><DEDENT>elif align == '<STR_LIT:right>':<EOL><INDENT>boffset += totwidth<EOL><DEDENT>elif align != '<STR_LIT:left>' and align != '<STR_LIT>':<EOL><INDENT>raise ValueError('<STR_LIT>' % align)<EOL><DEDENT>if orientation == '<STR_LIT>':<EOL><INDENT>for m in n:<EOL><INDENT>color = self._get_lines._get_next_cycle_color()<EOL>patch = self.barh(bins[:-<NUM_LIT:1>]+boffset, m, height=width,<EOL>left=bottom, align='<STR_LIT>', log=log,<EOL>color=color)<EOL>patches.append(patch)<EOL>if stacked:<EOL><INDENT>if bottom is None: bottom = <NUM_LIT:0.0><EOL>bottom += m<EOL><DEDENT>boffset += dw<EOL><DEDENT><DEDENT>elif orientation == '<STR_LIT>':<EOL><INDENT>for m in n:<EOL><INDENT>color = self._get_lines._get_next_cycle_color()<EOL>patch = self.bar(bins[:-<NUM_LIT:1>]+boffset, m, width=width,<EOL>bottom=bottom, align='<STR_LIT>', log=log,<EOL>color=color)<EOL>patches.append(patch)<EOL>if stacked:<EOL><INDENT>if bottom is None: bottom = <NUM_LIT:0.0><EOL>bottom += m<EOL><DEDENT>boffset += dw<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % orientation)<EOL><DEDENT><DEDENT>elif histtype.startswith('<STR_LIT>'):<EOL><INDENT>x = np.zeros( <NUM_LIT:2>*len(bins), np.float )<EOL>y = np.zeros( <NUM_LIT:2>*len(bins), np.float )<EOL>x[<NUM_LIT:0>::<NUM_LIT:2>], x[<NUM_LIT:1>::<NUM_LIT:2>] = bins, bins<EOL>if align == '<STR_LIT:left>' or align == '<STR_LIT>':<EOL><INDENT>x -= <NUM_LIT:0.5>*(bins[<NUM_LIT:1>]-bins[<NUM_LIT:0>])<EOL><DEDENT>elif align == '<STR_LIT:right>':<EOL><INDENT>x += <NUM_LIT:0.5>*(bins[<NUM_LIT:1>]-bins[<NUM_LIT:0>])<EOL><DEDENT>elif align != '<STR_LIT>' and align != '<STR_LIT>':<EOL><INDENT>raise ValueError('<STR_LIT>' % align)<EOL><DEDENT>if log:<EOL><INDENT>y[<NUM_LIT:0>],y[-<NUM_LIT:1>] = <NUM_LIT>, <NUM_LIT><EOL>if orientation == '<STR_LIT>':<EOL><INDENT>self.set_xscale('<STR_LIT>')<EOL><DEDENT>elif orientation == '<STR_LIT>':<EOL><INDENT>self.set_yscale('<STR_LIT>')<EOL><DEDENT><DEDENT>fill = False<EOL>if histtype == '<STR_LIT>':<EOL><INDENT>fill = True<EOL><DEDENT>elif histtype != '<STR_LIT>':<EOL><INDENT>raise ValueError('<STR_LIT>' % histtype)<EOL><DEDENT>for m in n:<EOL><INDENT>y[<NUM_LIT:1>:-<NUM_LIT:1>:<NUM_LIT:2>], y[<NUM_LIT:2>::<NUM_LIT:2>] = m, m<EOL>if orientation == '<STR_LIT>':<EOL><INDENT>x,y = y,x<EOL><DEDENT>elif orientation != '<STR_LIT>':<EOL><INDENT>raise ValueError('<STR_LIT>' % orientation)<EOL><DEDENT>color = self._get_lines._get_next_cycle_color()<EOL>if fill:<EOL><INDENT>patches.append( self.fill(x, y,<EOL>closed=False, facecolor=color) )<EOL><DEDENT>else:<EOL><INDENT>patches.append( self.fill(x, y,<EOL>closed=False, edgecolor=color, fill=False) )<EOL><DEDENT><DEDENT>if orientation == '<STR_LIT>':<EOL><INDENT>xmin, xmax = <NUM_LIT:0>, self.dataLim.intervalx[<NUM_LIT:1>]<EOL>for m in n:<EOL><INDENT>xmin = np.amin(m[m!=<NUM_LIT:0>]) <EOL><DEDENT>xmin = max(xmin*<NUM_LIT>, <NUM_LIT>)<EOL>self.dataLim.intervalx = (xmin, xmax)<EOL><DEDENT>elif orientation == '<STR_LIT>':<EOL><INDENT>ymin, ymax = <NUM_LIT:0>, self.dataLim.intervaly[<NUM_LIT:1>]<EOL>for m in n:<EOL><INDENT>ymin = np.amin(m[m!=<NUM_LIT:0>]) <EOL><DEDENT>ymin = max(ymin*<NUM_LIT>, <NUM_LIT>)<EOL>self.dataLim.intervaly = (ymin, ymax)<EOL><DEDENT>self.autoscale_view()<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % histtype)<EOL><DEDENT>label = kwargs.pop('<STR_LIT:label>', '<STR_LIT>')<EOL>for patch in patches:<EOL><INDENT>for p in patch:<EOL><INDENT>p.update(kwargs)<EOL>p.set_label(label)<EOL>label = '<STR_LIT>'<EOL><DEDENT><DEDENT>if binsgiven:<EOL><INDENT>self.set_autoscale_on(False)<EOL>if orientation == '<STR_LIT>':<EOL><INDENT>self.autoscale_view(scalex=False, scaley=True)<EOL>XL = self.xaxis.get_major_locator().view_limits(bins[<NUM_LIT:0>], bins[-<NUM_LIT:1>])<EOL>self.set_xbound(XL)<EOL><DEDENT>else:<EOL><INDENT>self.autoscale_view(scalex=True, scaley=False)<EOL>YL = self.yaxis.get_major_locator().view_limits(bins[<NUM_LIT:0>], bins[-<NUM_LIT:1>])<EOL>self.set_ybound(YL)<EOL><DEDENT><DEDENT>if len(n)==<NUM_LIT:1>:<EOL><INDENT>return n[<NUM_LIT:0>], bins, cbook.silent_list('<STR_LIT>', patches[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>return n, bins, cbook.silent_list('<STR_LIT>', patches)<EOL><DEDENT>

call signature::

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

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

Keyword arguments:

  *bins*:
    Either an integer number of bins or a sequence giving the
    bins.  *x* are the data to be binned. *x* can be an array,
    a 2D array with multiple data in its columns, or a list of
    arrays with data of different length.  Note, if *bins*
    is an integer input argument=numbins, *bins* + 1 bin edges
    will be returned, compatible with the semantics of
    :func:`numpy.histogram` with the *new* = True argument.
    Unequally spaced bins are supported if *bins* is a sequence.

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

    If *bins* is a sequence or *range* is specified, autoscaling is
    set off (*autoscale_on* is set to *False*) and the xaxis limits
    are set to encompass the full specified bin range.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

kwargs are used to update the properties of the hist
:class:`~matplotlib.patches.Rectangle` instances:

%(Rectangle)s

You can use labels for your histogram, and only the first
:class:`~matplotlib.patches.Rectangle` gets the label (the
others get the magic string '_nolegend_'.  This will make the
histograms work in the intuitive way for bar charts::

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

**Example:**

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


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

if not self._hold: self.cla()<EOL>pxx, freqs = mlab.psd(x, NFFT, Fs, detrend, window, noverlap, pad_to,<EOL>sides, scale_by_freq)<EOL>pxx.shape = len(freqs),<EOL>freqs += Fc<EOL>if scale_by_freq in (None, True):<EOL><INDENT>psd_units = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>psd_units = '<STR_LIT>'<EOL><DEDENT>self.plot(freqs, <NUM_LIT:10>*np.log10(pxx), **kwargs)<EOL>self.set_xlabel('<STR_LIT>')<EOL>self.set_ylabel('<STR_LIT>' % psd_units)<EOL>self.grid(True)<EOL>vmin, vmax = self.viewLim.intervaly<EOL>intv = vmax-vmin<EOL>logi = int(np.log10(intv))<EOL>if logi==<NUM_LIT:0>: logi=<NUM_LIT><EOL>step = <NUM_LIT:10>*logi<EOL>ticks = np.arange(math.floor(vmin), math.ceil(vmax)+<NUM_LIT:1>, step)<EOL>self.set_yticks(ticks)<EOL>return pxx, freqs<EOL>

call signature::

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

The power spectral density by Welch's average periodogram
method.  The vector *x* is divided into *NFFT* length
segments.  Each segment is detrended by function *detrend* and
windowed by function *window*.  *noverlap* gives the length of
the overlap between segments.  The :math:`|\mathrm{fft}(i)|^2`
of each segment :math:`i` are averaged to compute *Pxx*, with a
scaling to correct for power loss due to windowing.  *Fs* is the
sampling frequency.

%(PSD)s

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

Returns the tuple (*Pxx*, *freqs*).

For plotting, the power is plotted as
:math:`10\log_{10}(P_{xx})` for decibels, though *Pxx* itself
is returned.

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

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

%(Line2D)s

**Example:**

.. plot:: mpl_examples/pylab_examples/psd_demo.py


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

if not self._hold: self.cla()<EOL>pxy, freqs = mlab.csd(x, y, NFFT, Fs, detrend, window, noverlap,<EOL>pad_to, sides, scale_by_freq)<EOL>pxy.shape = len(freqs),<EOL>freqs += Fc<EOL>self.plot(freqs, <NUM_LIT:10>*np.log10(np.absolute(pxy)), **kwargs)<EOL>self.set_xlabel('<STR_LIT>')<EOL>self.set_ylabel('<STR_LIT>')<EOL>self.grid(True)<EOL>vmin, vmax = self.viewLim.intervaly<EOL>intv = vmax-vmin<EOL>step = <NUM_LIT:10>*int(np.log10(intv))<EOL>ticks = np.arange(math.floor(vmin), math.ceil(vmax)+<NUM_LIT:1>, step)<EOL>self.set_yticks(ticks)<EOL>return pxy, freqs<EOL>

call signature::

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

The cross spectral density :math:`P_{xy}` by Welch's average
periodogram method.  The vectors *x* and *y* are divided into
*NFFT* length segments.  Each segment is detrended by function
*detrend* and windowed by function *window*.  The product of
the direct FFTs of *x* and *y* are averaged over each segment
to compute :math:`P_{xy}`, with a scaling to correct for power
loss due to windowing.

Returns the tuple (*Pxy*, *freqs*).  *P* is the cross spectrum
(complex valued), and :math:`10\log_{10}|P_{xy}|` is
plotted.

%(PSD)s

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

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

kwargs control the Line2D properties:

%(Line2D)s

**Example:**

.. plot:: mpl_examples/pylab_examples/csd_demo.py

.. seealso:
    :meth:`psd`
        For a description of the optional parameters.


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

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

call signature::

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

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

.. math::

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

%(PSD)s

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

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

kwargs are applied to the lines.

References:

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

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

%(Line2D)s

**Example:**

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


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

if not self._hold: self.cla()<EOL>Pxx, freqs, bins = mlab.specgram(x, NFFT, Fs, detrend,<EOL>window, noverlap, pad_to, sides, scale_by_freq)<EOL>Z = <NUM_LIT> * np.log10(Pxx)<EOL>Z = np.flipud(Z)<EOL>if xextent is None: xextent = <NUM_LIT:0>, np.amax(bins)<EOL>xmin, xmax = xextent<EOL>freqs += Fc<EOL>extent = xmin, xmax, freqs[<NUM_LIT:0>], freqs[-<NUM_LIT:1>]<EOL>im = self.imshow(Z, cmap, extent=extent)<EOL>self.axis('<STR_LIT>')<EOL>return Pxx, freqs, bins, im<EOL>

call signature::

  specgram(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
           window=mlab.window_hanning, noverlap=128,
           cmap=None, xextent=None, pad_to=None, sides='default',
           scale_by_freq=None)

Compute a spectrogram of data in *x*.  Data are split into
*NFFT* length segments and the PSD of each section is
computed.  The windowing function *window* is applied to each
segment, and the amount of overlap of each segment is
specified with *noverlap*.

%(PSD)s

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

  *cmap*:
    A :class:`matplotlib.cm.Colormap` instance; if *None* use
    default determined by rc

  *xextent*:
    The image extent along the x-axis. xextent = (xmin,xmax)
    The default is (0,max(bins)), where bins is the return
    value from :func:`mlab.specgram`

Return value is (*Pxx*, *freqs*, *bins*, *im*):

  - *bins* are the time points the spectrogram is calculated over
  - *freqs* is an array of frequencies
  - *Pxx* is a len(times) x len(freqs) array of power
  - *im* is a :class:`matplotlib.image.AxesImage` instance

Note: If *x* is real (i.e. non-complex), only the positive
spectrum is shown.  If *x* is complex, both positive and
negative parts of the spectrum are shown.  This can be
overridden using the *sides* keyword argument.

**Example:**

.. plot:: mpl_examples/pylab_examples/specgram_demo.py


def spy(self, Z, precision=<NUM_LIT:0>, marker=None, markersize=None,<EOL>aspect='<STR_LIT>',  **kwargs):

if precision is None:<EOL><INDENT>precision = <NUM_LIT:0><EOL>warnings.DeprecationWarning("<STR_LIT>")<EOL><DEDENT>if marker is None and markersize is None and hasattr(Z, '<STR_LIT>'):<EOL><INDENT>marker = '<STR_LIT:s>'<EOL><DEDENT>if marker is None and markersize is None:<EOL><INDENT>Z = np.asarray(Z)<EOL>mask = np.absolute(Z)>precision<EOL>if '<STR_LIT>' not in kwargs:<EOL><INDENT>kwargs['<STR_LIT>'] = mcolors.ListedColormap(['<STR_LIT:w>', '<STR_LIT:k>'],<EOL>name='<STR_LIT>')<EOL><DEDENT>nr, nc = Z.shape<EOL>extent = [-<NUM_LIT:0.5>, nc-<NUM_LIT:0.5>, nr-<NUM_LIT:0.5>, -<NUM_LIT:0.5>]<EOL>ret = self.imshow(mask, interpolation='<STR_LIT>', aspect=aspect,<EOL>extent=extent, origin='<STR_LIT>', **kwargs)<EOL><DEDENT>else:<EOL><INDENT>if hasattr(Z, '<STR_LIT>'):<EOL><INDENT>c = Z.tocoo()<EOL>if precision == '<STR_LIT>':<EOL><INDENT>y = c.row<EOL>x = c.col<EOL><DEDENT>else:<EOL><INDENT>nonzero = np.absolute(c.data) > precision<EOL>y = c.row[nonzero]<EOL>x = c.col[nonzero]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>Z = np.asarray(Z)<EOL>nonzero = np.absolute(Z)>precision<EOL>y, x = np.nonzero(nonzero)<EOL><DEDENT>if marker is None: marker = '<STR_LIT:s>'<EOL>if markersize is None: markersize = <NUM_LIT:10><EOL>marks = mlines.Line2D(x, y, linestyle='<STR_LIT:None>',<EOL>marker=marker, markersize=markersize, **kwargs)<EOL>self.add_line(marks)<EOL>nr, nc = Z.shape<EOL>self.set_xlim(xmin=-<NUM_LIT:0.5>, xmax=nc-<NUM_LIT:0.5>)<EOL>self.set_ylim(ymin=nr-<NUM_LIT:0.5>, ymax=-<NUM_LIT:0.5>)<EOL>self.set_aspect(aspect)<EOL>ret = marks<EOL><DEDENT>self.title.set_y(<NUM_LIT>)<EOL>self.xaxis.tick_top()<EOL>self.xaxis.set_ticks_position('<STR_LIT>')<EOL>self.xaxis.set_major_locator(mticker.MaxNLocator(nbins=<NUM_LIT:9>,<EOL>steps=[<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:5>, <NUM_LIT:10>],<EOL>integer=True))<EOL>self.yaxis.set_major_locator(mticker.MaxNLocator(nbins=<NUM_LIT:9>,<EOL>steps=[<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:5>, <NUM_LIT:10>],<EOL>integer=True))<EOL>return ret<EOL>

call signature::

  spy(Z, precision=0, marker=None, markersize=None,
      aspect='equal', **kwargs)

``spy(Z)`` plots the sparsity pattern of the 2-D array *Z*.

If *precision* is 0, any non-zero value will be plotted;
else, values of :math:`|Z| > precision` will be plotted.

For :class:`scipy.sparse.spmatrix` instances, there is a
special case: if *precision* is 'present', any value present in
the array will be plotted, even if it is identically zero.

The array will be plotted as it would be printed, with
the first index (row) increasing down and the second
index (column) increasing to the right.

By default aspect is 'equal', so that each array element
occupies a square space; set the aspect kwarg to 'auto'
to allow the plot to fill the plot box, or to any scalar
number to specify the aspect ratio of an array element
directly.

Two plotting styles are available: image or marker. Both
are available for full arrays, but only the marker style
works for :class:`scipy.sparse.spmatrix` instances.

If *marker* and *markersize* are *None*, an image will be
returned and any remaining kwargs are passed to
:func:`~matplotlib.pyplot.imshow`; else, a
:class:`~matplotlib.lines.Line2D` object will be returned with
the value of marker determining the marker type, and any
remaining kwargs passed to the
:meth:`~matplotlib.axes.Axes.plot` method.

If *marker* and *markersize* are *None*, useful kwargs include:

* *cmap*
* *alpha*

.. seealso::
    :func:`~matplotlib.pyplot.imshow`

For controlling colors, e.g. cyan background and red marks,
use::

  cmap = mcolors.ListedColormap(['c','r'])

If *marker* or *markersize* is not *None*, useful kwargs include:

* *marker*
* *markersize*
* *color*

Useful values for *marker* include:

* 's'  square (default)
* 'o'  circle
* '.'  point
* ','  pixel

.. seealso::
    :func:`~matplotlib.pyplot.plot`


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

Plot a matrix or array as an image.

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

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

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

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


def __init__(self, fig, *args, **kwargs):

self.figure = fig<EOL>if len(args)==<NUM_LIT:1>:<EOL><INDENT>s = str(args[<NUM_LIT:0>])<EOL>if len(s) != <NUM_LIT:3>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>rows, cols, num = list(map(int, s))<EOL><DEDENT>elif len(args)==<NUM_LIT:3>:<EOL><INDENT>rows, cols, num = args<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(  '<STR_LIT>')<EOL><DEDENT>total = rows*cols<EOL>num -= <NUM_LIT:1>    <EOL>if num >= total:<EOL><INDENT>raise ValueError( '<STR_LIT>')<EOL><DEDENT>self._rows = rows<EOL>self._cols = cols<EOL>self._num = num<EOL>self.update_params()<EOL>self._axes_class.__init__(self, fig, self.figbox, **kwargs)<EOL>

*fig* is a :class:`matplotlib.figure.Figure` instance.

*args* is the tuple (*numRows*, *numCols*, *plotNum*), where
the array of subplots in the figure has dimensions *numRows*,
*numCols*, and where *plotNum* is the number of the subplot
being created.  *plotNum* starts at 1 in the upper left
corner and increases to the right.

If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.


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


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

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

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


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

update the subplot position from fig.subplotpars


lastrow = self.is_last_row()<EOL>firstcol = self.is_first_col()<EOL>for label in self.get_xticklabels():<EOL><INDENT>label.set_visible(lastrow)<EOL><DEDENT>for label in self.get_yticklabels():<EOL><INDENT>label.set_visible(firstcol)<EOL><DEDENT>

set the visible property on ticklabels so xticklabels are
visible only if the subplot is in the last row and yticklabels
are visible only if the subplot is in the first column


lx = math.floor(math.log(x)/math.log(base))<EOL>return base**lx<EOL>


lx = math.ceil(math.log(x)/math.log(base))<EOL>return base**lx<EOL>


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

Return the format for tick val x at position pos; pos=None indicated unspecified


return self.format_data(value)<EOL>


return s<EOL>

some classes may want to replace a hyphen for minus with the
proper unicode symbol as described `here
<http://sourceforge.net/tracker/index.php?func=detail&aid=1962574&group_id=80706&atid=560720>`_.
The default is to do nothing

Note, if you use this method, eg in :meth`format_data` or
call, you probably don't want to use it for
:meth:`format_data_short` since the toolbar uses this for
interative coord reporting and I doubt we can expect GUIs
across platforms will handle the unicode correctly.  So for
now the classes that override :meth:`fix_minus` should have an
explicit :meth:`format_data_short` method


return '<STR_LIT>'<EOL>

Return the format for tick val *x* at position *pos*


self.seq = seq<EOL>self.offset_string = '<STR_LIT>'<EOL>

seq is a sequence of strings.  For positions `i<len(seq)` return
*seq[i]* regardless of *x*.  Otherwise return ''


if pos is None or pos>=len(self.seq): return '<STR_LIT>'<EOL>else: return self.seq[pos]<EOL>


return self.func(x, pos)<EOL>


return self.fmt % x<EOL>


xmin, xmax = self.axis.get_view_interval()<EOL>d = abs(xmax - xmin)<EOL>return self.pprint_val(x,d)<EOL>


if rcParams['<STR_LIT>'] or not rcParams['<STR_LIT>']: return s<EOL>else: return s.replace('<STR_LIT:->', '<STR_LIT>')<EOL>


if len(self.locs)==<NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>s = self.pprint_val(x)<EOL>return self.fix_minus(s)<EOL><DEDENT>


self._scientific = bool(b)<EOL>

True or False to turn scientific notation on or off
        see also :meth:`set_powerlimits`


assert len(lims) == <NUM_LIT:2>, "<STR_LIT>"<EOL>self._powerlimits = lims<EOL>

Sets size thresholds for scientific notation.

e.g. ``xaxis.set_powerlimits((-3, 4))`` sets the pre-2007 default in
which scientific notation is used for numbers less than
1e-3 or greater than 1e4.
See also :meth:`set_scientific`.


return '<STR_LIT>'%value<EOL>

return a short formatted string representation of a number


s =  self._formatSciNotation('<STR_LIT>'% value)<EOL>return self.fix_minus(s)<EOL>

return a formatted string representation of a number


if len(self.locs)==<NUM_LIT:0>: return '<STR_LIT>'<EOL>s = '<STR_LIT>'<EOL>if self.orderOfMagnitude or self.offset:<EOL><INDENT>offsetStr = '<STR_LIT>'<EOL>sciNotStr = '<STR_LIT>'<EOL>if self.offset:<EOL><INDENT>offsetStr = self.format_data(self.offset)<EOL>if self.offset > <NUM_LIT:0>: offsetStr = '<STR_LIT:+>' + offsetStr<EOL><DEDENT>if self.orderOfMagnitude:<EOL><INDENT>if self._usetex or self._useMathText:<EOL><INDENT>sciNotStr = self.format_data(<NUM_LIT:10>**self.orderOfMagnitude)<EOL><DEDENT>else:<EOL><INDENT>sciNotStr = '<STR_LIT>'% self.orderOfMagnitude<EOL><DEDENT><DEDENT>if self._useMathText:<EOL><INDENT>if sciNotStr != '<STR_LIT>':<EOL><INDENT>sciNotStr = r'<STR_LIT>' % sciNotStr<EOL><DEDENT>s = '<STR_LIT>'.join(('<STR_LIT:$>',sciNotStr,r'<STR_LIT>',offsetStr,'<STR_LIT>'))<EOL><DEDENT>elif self._usetex:<EOL><INDENT>if sciNotStr != '<STR_LIT>':<EOL><INDENT>sciNotStr = r'<STR_LIT>' % sciNotStr<EOL><DEDENT>s =  '<STR_LIT>'.join(('<STR_LIT:$>',sciNotStr,offsetStr,'<STR_LIT:$>'))<EOL><DEDENT>else:<EOL><INDENT>s =  '<STR_LIT>'.join((sciNotStr,offsetStr))<EOL><DEDENT><DEDENT>return self.fix_minus(s)<EOL>


self.locs = locs<EOL>if len(self.locs) > <NUM_LIT:0>:<EOL><INDENT>vmin, vmax = self.axis.get_view_interval()<EOL>d = abs(vmax-vmin)<EOL>if self._useOffset: self._set_offset(d)<EOL>self._set_orderOfMagnitude(d)<EOL>self._set_format()<EOL><DEDENT>


def __init__(self, base=<NUM_LIT>, labelOnlyBase = True):

self._base = base+<NUM_LIT:0.0><EOL>self.labelOnlyBase=labelOnlyBase<EOL>self.decadeOnly = True<EOL>

*base* is used to locate the decade tick,
which will be the only one to be labeled if *labelOnlyBase*
is ``False``


change the *base* for labeling - warning: should always match the base used for :class:`LogLocator`


self.labelOnlyBase=labelOnlyBase<EOL>


vmin, vmax = self.axis.get_view_interval()<EOL>d = abs(vmax - vmin)<EOL>b=self._base<EOL>if x == <NUM_LIT:0.0>:<EOL><INDENT>return '<STR_LIT:0>'<EOL><DEDENT>sign = np.sign(x)<EOL>fx = math.log(abs(x))/math.log(b)<EOL>isDecade = self.is_decade(fx)<EOL>if not isDecade and self.labelOnlyBase: s = '<STR_LIT>'<EOL>elif x><NUM_LIT>: s= '<STR_LIT>'%x<EOL>elif x<<NUM_LIT:1>: s =  '<STR_LIT>'%x<EOL>else        : s =  self.pprint_val(x,d)<EOL>if sign == -<NUM_LIT:1>:<EOL><INDENT>s =  '<STR_LIT>' % s<EOL><DEDENT>return self.fix_minus(s)<EOL>


return '<STR_LIT>'%value<EOL>


vmin, vmax = self.axis.get_view_interval()<EOL>vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = <NUM_LIT>)<EOL>d = abs(vmax-vmin)<EOL>b=self._base<EOL>if x == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT:0>'<EOL><DEDENT>sign = np.sign(x)<EOL>fx = math.log(abs(x))/math.log(b)<EOL>isDecade = self.is_decade(fx)<EOL>if not isDecade and self.labelOnlyBase: s = '<STR_LIT>'<EOL>elif fx><NUM_LIT>: s= '<STR_LIT>'%fx<EOL>elif fx<<NUM_LIT:1>: s =  '<STR_LIT>'%fx<EOL>else        : s =  self.pprint_val(fx,d)<EOL>if sign == -<NUM_LIT:1>:<EOL><INDENT>s =  '<STR_LIT>' % s<EOL><DEDENT>return self.fix_minus(s)<EOL>


b = self._base<EOL>if x == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>sign = np.sign(x)<EOL>fx = math.log(abs(x))/math.log(b)<EOL>isDecade = self.is_decade(fx)<EOL>usetex = rcParams['<STR_LIT>']<EOL>if sign == -<NUM_LIT:1>:<EOL><INDENT>sign_string = '<STR_LIT:->'<EOL><DEDENT>else:<EOL><INDENT>sign_string = '<STR_LIT>'<EOL><DEDENT>if not isDecade and self.labelOnlyBase: s = '<STR_LIT>'<EOL>elif not isDecade:<EOL><INDENT>if usetex:<EOL><INDENT>s = r'<STR_LIT>'% (sign_string, b, fx)<EOL><DEDENT>else:<EOL><INDENT>s = '<STR_LIT>'% (sign_string, b, fx)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if usetex:<EOL><INDENT>s = r'<STR_LIT>'% (sign_string, b, self.nearest_long(fx))<EOL><DEDENT>else:<EOL><INDENT>s = r'<STR_LIT>'% (sign_string, b, self.nearest_long(fx))<EOL><DEDENT><DEDENT>return s<EOL>


return mtransforms.nonsingular(vmin, vmax)<EOL>

select a scale for the range from vmin to vmax

Normally This will be overridden.


return self.view_limits(*self.axis.get_view_interval())<EOL>


ticks = self()<EOL>numticks = len(ticks)<EOL>vmin, vmax = self.axis.get_view_interval()<EOL>vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = <NUM_LIT>)<EOL>if numticks><NUM_LIT:2>:<EOL><INDENT>step = numsteps*abs(ticks[<NUM_LIT:0>]-ticks[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>d = abs(vmax-vmin)<EOL>step = numsteps*d/<NUM_LIT><EOL><DEDENT>vmin += step<EOL>vmax += step<EOL>self.axis.set_view_interval(vmin, vmax, ignore=True)<EOL>

Pan numticks (can be positive or negative)


vmin, vmax = self.axis.get_view_interval()<EOL>vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = <NUM_LIT>)<EOL>interval = abs(vmax-vmin)<EOL>step = <NUM_LIT:0.1>*interval*direction<EOL>self.axis.set_view_interval(vmin + step, vmax - step, ignore=True)<EOL>

Zoom in/out on axis; if direction is >0 zoom in, else zoom out


pass<EOL>

refresh internal information based on current lim


self._base = base<EOL>self.offset = offset<EOL>

place ticks on the i-th data points where (i-offset)%base==0


dmin, dmax = self.axis.get_data_interval()<EOL>return np.arange(dmin + self.offset, dmax+<NUM_LIT:1>, self._base)<EOL>


if self.nbins is None:<EOL><INDENT>return self.locs<EOL><DEDENT>step = max(int(<NUM_LIT> + len(self.locs) / float(self.nbins)), <NUM_LIT:1>)<EOL>return self.locs[::step]<EOL>


return []<EOL>


def __init__(self, numticks = None, presets=None):

self.numticks = numticks<EOL>if presets is None:<EOL><INDENT>self.presets = {}<EOL><DEDENT>else:<EOL><INDENT>self.presets = presets<EOL><DEDENT>

Use presets to set locs based on lom.  A dict mapping vmin, vmax->locs


vmin, vmax = self.axis.get_view_interval()<EOL>vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = <NUM_LIT>)<EOL>if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>if (vmin, vmax) in self.presets:<EOL><INDENT>return self.presets[(vmin, vmax)]<EOL><DEDENT>if self.numticks is None:<EOL><INDENT>self._set_numticks()<EOL><DEDENT>if self.numticks==<NUM_LIT:0>: return []<EOL>ticklocs = np.linspace(vmin, vmax, self.numticks)<EOL>return ticklocs<EOL>


if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>if vmin==vmax:<EOL><INDENT>vmin-=<NUM_LIT:1><EOL>vmax+=<NUM_LIT:1><EOL><DEDENT>exponent, remainder = divmod(math.log10(vmax - vmin), <NUM_LIT:1>)<EOL>if remainder < <NUM_LIT:0.5>:<EOL><INDENT>exponent -= <NUM_LIT:1><EOL><DEDENT>scale = <NUM_LIT:10>**(-exponent)<EOL>vmin = math.floor(scale*vmin)/scale<EOL>vmax = math.ceil(scale*vmax)/scale<EOL>return mtransforms.nonsingular(vmin, vmax)<EOL>

Try to choose the view limits intelligently


d,m = divmod(x, self._base)<EOL>if closeto(m,<NUM_LIT:0>) and not closeto(m/self._base,<NUM_LIT:1>):<EOL><INDENT>return (d-<NUM_LIT:1>)*self._base<EOL><DEDENT>return d*self._base<EOL>


d,m = divmod(x, self._base)<EOL>if closeto(m/self._base,<NUM_LIT:1>): <EOL><INDENT>return (d+<NUM_LIT:1>)*self._base<EOL><DEDENT>return d*self._base<EOL>

return the largest multiple of base <= x


d,m = divmod(x, self._base)<EOL>if closeto(m/self._base,<NUM_LIT:1>):<EOL><INDENT>return (d+<NUM_LIT:2>)*self._base<EOL><DEDENT>return (d+<NUM_LIT:1>)*self._base<EOL>

return the smallest multiple of base > x


d,m = divmod(x, self._base)<EOL>if closeto(m,<NUM_LIT:0>) and not closeto(m/self._base,<NUM_LIT:1>):<EOL><INDENT>return d*self._base<EOL><DEDENT>return (d+<NUM_LIT:1>)*self._base<EOL>

return the smallest multiple of base >= x


vmin, vmax = self.axis.get_view_interval()<EOL>if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>vmin = self._base.ge(vmin)<EOL>base = self._base.get_base()<EOL>n = (vmax - vmin + <NUM_LIT>*base)//base<EOL>locs = vmin + np.arange(n+<NUM_LIT:1>) * base<EOL>return locs<EOL>


vmin = self._base.le(dmin)<EOL>vmax = self._base.ge(dmax)<EOL>if vmin==vmax:<EOL><INDENT>vmin -=<NUM_LIT:1><EOL>vmax +=<NUM_LIT:1><EOL><DEDENT>return mtransforms.nonsingular(vmin, vmax)<EOL>

Set the view limits to the nearest multiples of base that
contain the data


def __init__(self, base=<NUM_LIT>, subs=[<NUM_LIT:1.0>]):

self.base(base)<EOL>self.subs(subs)<EOL>self.numticks = <NUM_LIT:15><EOL>

place ticks on the location= base**i*subs[j]


set the base of the log scaling (major tick every base**i, i interger)


if subs is None:<EOL><INDENT>self._subs = None  <EOL><DEDENT>else:<EOL><INDENT>self._subs = np.asarray(subs)+<NUM_LIT:0.0><EOL><DEDENT>

set the minor ticks the log scaling every base**i*subs[j]


b=self._base<EOL>vmin, vmax = self.axis.get_view_interval()<EOL>if vmin <= <NUM_LIT:0.0>:<EOL><INDENT>vmin = self.axis.get_minpos()<EOL>if vmin <= <NUM_LIT:0.0>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>vmin = math.log(vmin)/math.log(b)<EOL>vmax = math.log(vmax)/math.log(b)<EOL>if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>numdec = math.floor(vmax)-math.ceil(vmin)<EOL>if self._subs is None: <EOL><INDENT>if numdec><NUM_LIT:10>: subs = np.array([<NUM_LIT:1.0>])<EOL>elif numdec><NUM_LIT:6>: subs = np.arange(<NUM_LIT>, b, <NUM_LIT>)<EOL>else: subs = np.arange(<NUM_LIT>, b)<EOL><DEDENT>else:<EOL><INDENT>subs = self._subs<EOL><DEDENT>stride = <NUM_LIT:1><EOL>while numdec/stride+<NUM_LIT:1> > self.numticks:<EOL><INDENT>stride += <NUM_LIT:1><EOL><DEDENT>decades = np.arange(math.floor(vmin),<EOL>math.ceil(vmax)+stride, stride)<EOL>if len(subs) > <NUM_LIT:1> or (len(subs == <NUM_LIT:1>) and subs[<NUM_LIT:0>] != <NUM_LIT:1.0>):<EOL><INDENT>ticklocs = []<EOL>for decadeStart in b**decades:<EOL><INDENT>ticklocs.extend( subs*decadeStart )<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ticklocs = b**decades<EOL><DEDENT>return np.array(ticklocs)<EOL>


if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>minpos = self.axis.get_minpos()<EOL>if minpos<=<NUM_LIT:0>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT>if vmin <= minpos:<EOL><INDENT>vmin = minpos<EOL><DEDENT>if not is_decade(vmin,self._base): vmin = decade_down(vmin,self._base)<EOL>if not is_decade(vmax,self._base): vmax = decade_up(vmax,self._base)<EOL>if vmin==vmax:<EOL><INDENT>vmin = decade_down(vmin,self._base)<EOL>vmax = decade_up(vmax,self._base)<EOL><DEDENT>result = mtransforms.nonsingular(vmin, vmax)<EOL>return result<EOL>


def __init__(self, transform, subs=[<NUM_LIT:1.0>]):

self._transform = transform<EOL>self._subs = subs<EOL>self.numticks = <NUM_LIT:15><EOL>


b = self._transform.base<EOL>vmin, vmax = self.axis.get_view_interval()<EOL>vmin, vmax = self._transform.transform((vmin, vmax))<EOL>if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>numdec = math.floor(vmax)-math.ceil(vmin)<EOL>if self._subs is None:<EOL><INDENT>if numdec><NUM_LIT:10>: subs = np.array([<NUM_LIT:1.0>])<EOL>elif numdec><NUM_LIT:6>: subs = np.arange(<NUM_LIT>, b, <NUM_LIT>)<EOL>else: subs = np.arange(<NUM_LIT>, b)<EOL><DEDENT>else:<EOL><INDENT>subs = np.asarray(self._subs)<EOL><DEDENT>stride = <NUM_LIT:1><EOL>while numdec/stride+<NUM_LIT:1> > self.numticks:<EOL><INDENT>stride += <NUM_LIT:1><EOL><DEDENT>decades = np.arange(math.floor(vmin), math.ceil(vmax)+stride, stride)<EOL>if len(subs) > <NUM_LIT:1> or subs[<NUM_LIT:0>] != <NUM_LIT:1.0>:<EOL><INDENT>ticklocs = []<EOL>for decade in decades:<EOL><INDENT>ticklocs.extend(subs * (np.sign(decade) * b ** np.abs(decade)))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ticklocs = np.sign(decades) * b ** np.abs(decades)<EOL><DEDENT>return np.array(ticklocs)<EOL>


b = self._transform.base<EOL>if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>if not is_decade(abs(vmin), b):<EOL><INDENT>if vmin < <NUM_LIT:0>:<EOL><INDENT>vmin = -decade_up(-vmin, b)<EOL><DEDENT>else:<EOL><INDENT>vmin = decade_down(vmin, b)<EOL><DEDENT><DEDENT>if not is_decade(abs(vmax), b):<EOL><INDENT>if vmax < <NUM_LIT:0>:<EOL><INDENT>vmax = -decade_down(-vmax, b)<EOL><DEDENT>else:<EOL><INDENT>vmax = decade_up(vmax, b)<EOL><DEDENT><DEDENT>if vmin == vmax:<EOL><INDENT>if vmin < <NUM_LIT:0>:<EOL><INDENT>vmin = -decade_up(-vmin, b)<EOL>vmax = -decade_down(-vmax, b)<EOL><DEDENT>else:<EOL><INDENT>vmin = decade_down(vmin, b)<EOL>vmax = decade_up(vmax, b)<EOL><DEDENT><DEDENT>result = mtransforms.nonsingular(vmin, vmax)<EOL>return result<EOL>


self.refresh()<EOL>return self._locator()<EOL>


vmin, vmax = self.axis.get_view_interval()<EOL>vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = <NUM_LIT>)<EOL>d = abs(vmax-vmin)<EOL>self._locator = self.get_locator(d)<EOL>


d = abs(vmax-vmin)<EOL>self._locator = self.get_locator(d)<EOL>return self._locator.view_limits(vmin, vmax)<EOL>


d = abs(d)<EOL>if d<=<NUM_LIT:0>:<EOL><INDENT>locator = MultipleLocator(<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>try: ld = math.log10(d)<EOL>except OverflowError:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>fld = math.floor(ld)<EOL>base = <NUM_LIT:10>**fld<EOL>if   d >= <NUM_LIT:5>*base : ticksize = base<EOL>elif d >= <NUM_LIT:2>*base : ticksize = base/<NUM_LIT><EOL>else             : ticksize = base/<NUM_LIT><EOL>locator = MultipleLocator(ticksize)<EOL><DEDENT>return locator<EOL>

pick the best locator based on a distance


def get_intersection(cx1, cy1, cos_t1, sin_t1,<EOL>cx2, cy2, cos_t2, sin_t2):

<EOL>line1_rhs = sin_t1 * cx1 - cos_t1 * cy1<EOL>line2_rhs = sin_t2 * cx2 - cos_t2 * cy2<EOL>a, b = sin_t1, -cos_t1<EOL>c, d = sin_t2, -cos_t2<EOL>ad_bc = a*d-b*c<EOL>if ad_bc == <NUM_LIT:0.>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>a_, b_ = d, -b<EOL>c_, d_ = -c, a<EOL>a_, b_, c_, d_ = [k / ad_bc for k in [a_, b_, c_, d_]]<EOL>x = a_* line1_rhs + b_ * line2_rhs<EOL>y = c_* line1_rhs + d_ * line2_rhs<EOL>return x, y<EOL>

return a intersecting point between a line through (cx1, cy1)
    and having angle t1 and a line through (cx2, cy2) and angle t2.


def get_normal_points(cx, cy, cos_t, sin_t, length):

if length == <NUM_LIT:0.>:<EOL><INDENT>return cx, cy, cx, cy<EOL><DEDENT>cos_t1, sin_t1 = sin_t, -cos_t<EOL>cos_t2, sin_t2 = -sin_t, cos_t<EOL>x1, y1 = length*cos_t1 + cx, length*sin_t1 + cy<EOL>x2, y2 = length*cos_t2 + cx, length*sin_t2 + cy<EOL>return x1, y1, x2, y2<EOL>

For a line passing through (*cx*, *cy*) and having a angle *t*,
return locations of the two points located along its perpendicular line at the distance of *length*.


beta = np.asarray(beta)<EOL>beta_list = [beta]<EOL>while True:<EOL><INDENT>beta = _de_casteljau1(beta, t)<EOL>beta_list.append(beta)<EOL>if len(beta) == <NUM_LIT:1>:<EOL><INDENT>break<EOL><DEDENT><DEDENT>left_beta = [beta[<NUM_LIT:0>] for beta in beta_list]<EOL>right_beta = [beta[-<NUM_LIT:1>] for beta in reversed(beta_list)]<EOL>return left_beta, right_beta<EOL>

split a bezier segment defined by its controlpoints *beta*
    into two separate segment divided at *t* and return their control points.


def find_bezier_t_intersecting_with_closedpath(bezier_point_at_t, inside_closedpath, <EOL>t0=<NUM_LIT:0.>, t1=<NUM_LIT:1.>, tolerence=<NUM_LIT>):

<EOL>start = bezier_point_at_t(t0)<EOL>end = bezier_point_at_t(t1)<EOL>start_inside = inside_closedpath(start)<EOL>end_inside = inside_closedpath(end)<EOL>if not xor(start_inside, end_inside):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>while <NUM_LIT:1>:<EOL><INDENT>if (start[<NUM_LIT:0>]-end[<NUM_LIT:0>])**<NUM_LIT:2> + (start[<NUM_LIT:1>]-end[<NUM_LIT:1>])**<NUM_LIT:2> < tolerence**<NUM_LIT:2>:<EOL><INDENT>return t0, t1<EOL><DEDENT>middle_t = <NUM_LIT:0.5>*(t0+t1)<EOL>middle = bezier_point_at_t(middle_t)<EOL>middle_inside = inside_closedpath(middle)<EOL>if xor(start_inside, middle_inside):<EOL><INDENT>t1 = middle_t<EOL>end = middle<EOL>end_inside = middle_inside<EOL><DEDENT>else:<EOL><INDENT>t0 = middle_t<EOL>start = middle<EOL>start_inside = middle_inside<EOL><DEDENT><DEDENT>

Find a parameter t0 and t1 of the given bezier path which
    bounds the intersecting points with a provided closed
    path(*inside_closedpath*). Search starts from *t0* and *t1* and it
    uses a simple bisecting algorithm therefore one of the end point
    must be inside the path while the orther doesn't. The search stop
    when |t0-t1| gets smaller than the given tolerence.
    value for

    - bezier_point_at_t : a function which returns x, y coordinates at *t*

    - inside_closedpath : return True if the point is insed the path


bz = BezierSegment(bezier)<EOL>bezier_point_at_t = bz.point_at_t<EOL>t0, t1 = find_bezier_t_intersecting_with_closedpath(bezier_point_at_t,<EOL>inside_closedpath, <EOL>tolerence=tolerence)<EOL>_left, _right = split_de_casteljau(bezier, (t0+t1)/<NUM_LIT>)<EOL>return _left, _right<EOL>

bezier : control points of the bezier segment
inside_closedpath : a function which returns true if the point is inside the path


def find_r_to_boundary_of_closedpath(inside_closedpath, xy,<EOL>cos_t, sin_t, <EOL>rmin=<NUM_LIT:0.>, rmax=<NUM_LIT:1.>, tolerence=<NUM_LIT>):

cx, cy = xy<EOL>def _f(r):<EOL><INDENT>return cos_t*r + cx, sin_t*r + cy<EOL><DEDENT>find_bezier_t_intersecting_with_closedpath(_f, inside_closedpath, <EOL>t0=rmin, t1=rmax, tolerence=tolerence)<EOL>

Find a radius r (centered at *xy*) between *rmin* and *rmax* at
which it intersect with the path.

inside_closedpath : function
cx, cy : center
cos_t, sin_t : cosine and sine for the angle
rmin, rmax :


def split_path_inout(path, inside, tolerence=<NUM_LIT>, reorder_inout=False):

path_iter = path.iter_segments()<EOL>ctl_points, command = path_iter.next()<EOL>begin_inside = inside(ctl_points[-<NUM_LIT:2>:]) <EOL>bezier_path = None<EOL>ctl_points_old = ctl_points<EOL>concat = np.concatenate<EOL>iold=<NUM_LIT:0><EOL>i = <NUM_LIT:1><EOL>for ctl_points, command in path_iter:<EOL><INDENT>iold=i<EOL>i += len(ctl_points)/<NUM_LIT:2><EOL>if inside(ctl_points[-<NUM_LIT:2>:]) != begin_inside:<EOL><INDENT>bezier_path = concat([ctl_points_old[-<NUM_LIT:2>:], ctl_points])<EOL>break<EOL><DEDENT>ctl_points_old = ctl_points<EOL><DEDENT>if bezier_path is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>bp = zip(bezier_path[::<NUM_LIT:2>], bezier_path[<NUM_LIT:1>::<NUM_LIT:2>])<EOL>left, right = split_bezier_intersecting_with_closedpath(bp,<EOL>inside,<EOL>tolerence)<EOL>if len(left) == <NUM_LIT:2>:<EOL><INDENT>codes_left = [Path.LINETO]<EOL>codes_right = [Path.MOVETO, Path.LINETO]<EOL><DEDENT>elif len(left) == <NUM_LIT:3>:<EOL><INDENT>codes_left = [Path.CURVE3, Path.CURVE3]<EOL>codes_right = [Path.MOVETO, Path.CURVE3, Path.CURVE3]<EOL><DEDENT>elif len(left) == <NUM_LIT:4>:<EOL><INDENT>codes_left = [Path.CURVE4, Path.CURVE4, Path.CURVE4]<EOL>codes_right = [Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4]<EOL><DEDENT>else:<EOL><INDENT>raise ValueError()<EOL><DEDENT>verts_left = left[<NUM_LIT:1>:]<EOL>verts_right = right[:]<EOL>if path.codes is None:<EOL><INDENT>path_in = Path(concat([path.vertices[:i], verts_left]))<EOL>path_out = Path(concat([verts_right, path.vertices[i:]]))<EOL><DEDENT>else:<EOL><INDENT>path_in = Path(concat([path.vertices[:iold], verts_left]),<EOL>concat([path.codes[:iold], codes_left]))<EOL>path_out = Path(concat([verts_right, path.vertices[i:]]),<EOL>concat([codes_right, path.codes[i:]]))<EOL><DEDENT>if reorder_inout and begin_inside == False:<EOL><INDENT>path_in, path_out = path_out, path_in<EOL><DEDENT>return path_in, path_out<EOL>

divide a path into two segment at the point where inside(x, y)
    becomes False.


<EOL>c1x, c1y = bezier2[<NUM_LIT:0>]<EOL>cmx, cmy = bezier2[<NUM_LIT:1>]<EOL>c2x, c2y = bezier2[<NUM_LIT:2>]<EOL>cos_t1, sin_t1 = get_cos_sin(c1x, c1y, cmx, cmy)<EOL>cos_t2, sin_t2 = get_cos_sin(cmx, cmy, c2x, c2y)<EOL>c1x_left, c1y_left, c1x_right, c1y_right =get_normal_points(c1x, c1y, cos_t1, sin_t1, width)<EOL>c2x_left, c2y_left, c2x_right, c2y_right =get_normal_points(c2x, c2y, cos_t2, sin_t2, width)<EOL>cmx_left, cmy_left = get_intersection(c1x_left, c1y_left, cos_t1, sin_t1,<EOL>c2x_left, c2y_left, cos_t2, sin_t2)<EOL>cmx_right, cmy_right = get_intersection(c1x_right, c1y_right, cos_t1, sin_t1,<EOL>c2x_right, c2y_right, cos_t2, sin_t2)<EOL>path_left = [(c1x_left, c1y_left), (cmx_left, cmy_left), (c2x_left, c2y_left)]<EOL>path_right = [(c1x_right, c1y_right), (cmx_right, cmy_right), (c2x_right, c2y_right)]<EOL>return path_left, path_right<EOL>

Given the quadraitc bezier control points *bezier2*, returns
control points of quadrativ bezier lines roughly parralel to given
one separated by *width*.


def make_wedged_bezier2(bezier2, length, shrink_factor=<NUM_LIT:0.5>):

xx1, yy1 = bezier2[<NUM_LIT:2>]<EOL>xx2, yy2 = bezier2[<NUM_LIT:1>]<EOL>xx3, yy3 = bezier2[<NUM_LIT:0>]<EOL>cx, cy = xx3, yy3<EOL>x0, y0 = xx2, yy2<EOL>dist = sqrt((x0-cx)**<NUM_LIT:2> + (y0-cy)**<NUM_LIT:2>)<EOL>cos_t, sin_t = (x0-cx)/dist, (y0-cy)/dist,<EOL>x1, y1, x2, y2 = get_normal_points(cx, cy, cos_t, sin_t, length)<EOL>xx12, yy12 = (xx1+xx2)/<NUM_LIT>, (yy1+yy2)/<NUM_LIT>, <EOL>xx23, yy23 = (xx2+xx3)/<NUM_LIT>, (yy2+yy3)/<NUM_LIT>, <EOL>dist = sqrt((xx12-xx23)**<NUM_LIT:2> + (yy12-yy23)**<NUM_LIT:2>)<EOL>cos_t, sin_t = (xx12-xx23)/dist, (yy12-yy23)/dist,<EOL>xm1, ym1, xm2, ym2 = get_normal_points(xx2, yy2, cos_t, sin_t, length*shrink_factor)<EOL>l_plus = [(x1, y1), (xm1, ym1), (xx1, yy1)]<EOL>l_minus = [(x2, y2), (xm2, ym2), (xx1, yy1)]<EOL>return l_plus, l_minus<EOL>

Being similar to get_parallels, returns
control points of two quadrativ bezier lines having a width roughly parralel to given
one separated by *width*.


def find_control_points(c1x, c1y, mmx, mmy, c2x, c2y):

cmx = <NUM_LIT> * (<NUM_LIT:4>*mmx - (c1x + c2x))<EOL>cmy = <NUM_LIT> * (<NUM_LIT:4>*mmy - (c1y + c2y))<EOL>return [(c1x, c1y), (cmx, cmy), (c2x, c2y)]<EOL>

Find control points of the bezier line throught c1, mm, c2. We
    simply assume that c1, mm, c2 which have parameteric value 0, 0.5, and 1.


def make_wedged_bezier2(bezier2, width, w1=<NUM_LIT:1.>, wm=<NUM_LIT:0.5>, w2=<NUM_LIT:0.>):

<EOL>c1x, c1y = bezier2[<NUM_LIT:0>]<EOL>cmx, cmy = bezier2[<NUM_LIT:1>]<EOL>c3x, c3y = bezier2[<NUM_LIT:2>]<EOL>cos_t1, sin_t1 = get_cos_sin(c1x, c1y, cmx, cmy)<EOL>cos_t2, sin_t2 = get_cos_sin(cmx, cmy, c3x, c3y)<EOL>c1x_left, c1y_left, c1x_right, c1y_right =get_normal_points(c1x, c1y, cos_t1, sin_t1, width*w1)<EOL>c3x_left, c3y_left, c3x_right, c3y_right =get_normal_points(c3x, c3y, cos_t2, sin_t2, width*w2)<EOL>c12x, c12y = (c1x+cmx)*<NUM_LIT>, (c1y+cmy)*<NUM_LIT><EOL>c23x, c23y = (cmx+c3x)*<NUM_LIT>, (cmy+c3y)*<NUM_LIT> <EOL>c123x, c123y = (c12x+c23x)*<NUM_LIT>, (c12y+c23y)*<NUM_LIT><EOL>cos_t123, sin_t123 = get_cos_sin(c12x, c12y, c23x, c23y)<EOL>c123x_left, c123y_left, c123x_right, c123y_right =get_normal_points(c123x, c123y, cos_t123, sin_t123, width*wm)<EOL>path_left = find_control_points(c1x_left, c1y_left,<EOL>c123x_left, c123y_left,<EOL>c3x_left, c3y_left)<EOL>path_right = find_control_points(c1x_right, c1y_right,<EOL>c123x_right, c123y_right,<EOL>c3x_right, c3y_right)<EOL>return path_left, path_right<EOL>


_o = len(control_points)<EOL>self._orders = np.arange(_o)<EOL>_coeff = BezierSegment._binom_coeff[_o - <NUM_LIT:1>]<EOL>_control_points = np.asarray(control_points)<EOL>xx = _control_points[:,<NUM_LIT:0>]<EOL>yy = _control_points[:,<NUM_LIT:1>]<EOL>self._px = xx * _coeff<EOL>self._py = yy * _coeff<EOL>

*control_points* : location of contol points. It needs have a
 shpae of n * 2, where n is the order of the bezier line. 1<=
 n <= 3 is supported.


one_minus_t_powers = np.power(<NUM_LIT:1.>-t, self._orders)[::-<NUM_LIT:1>]<EOL>t_powers = np.power(t, self._orders)<EOL>tt = one_minus_t_powers * t_powers<EOL>_x = sum(tt * self._px)<EOL>_y = sum(tt * self._py)<EOL>return _x, _y<EOL>


try:<EOL><INDENT>colorConverter.to_rgb(c)<EOL>return True<EOL><DEDENT>except ValueError:<EOL><INDENT>return False<EOL><DEDENT>

Return *True* if *c* can be converted to *RGB*


return '<STR_LIT>' % tuple([round(val*<NUM_LIT:255>) for val in rgb])<EOL>

Given a len 3 rgb tuple of 0-1 floats, return the hex string


if not isinstance(s, str):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>if hexColorPattern.match(s) is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % s)<EOL><DEDENT>return tuple([int(n, <NUM_LIT:16>)/<NUM_LIT> for n in (s[<NUM_LIT:1>:<NUM_LIT:3>], s[<NUM_LIT:3>:<NUM_LIT:5>], s[<NUM_LIT:5>:<NUM_LIT:7>])])<EOL>

Take a hex string *s* and return the corresponding rgb 3-tuple
Example: #efefef -> (0.93725, 0.93725, 0.93725)


try:<EOL><INDENT>adata = np.array(data)<EOL><DEDENT>except:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>shape = adata.shape<EOL>if len(shape) != <NUM_LIT:2> and shape[<NUM_LIT:1>] != <NUM_LIT:3>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>x  = adata[:,<NUM_LIT:0>]<EOL>y0 = adata[:,<NUM_LIT:1>]<EOL>y1 = adata[:,<NUM_LIT:2>]<EOL>if x[<NUM_LIT:0>] != <NUM_LIT:0.> or x[-<NUM_LIT:1>] != <NUM_LIT:1.0>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT>if np.sometrue(np.sort(x)-x):<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT>x = x * (N-<NUM_LIT:1>)<EOL>lut = np.zeros((N,), np.float)<EOL>xind = np.arange(float(N))<EOL>ind = np.searchsorted(x, xind)[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL>lut[<NUM_LIT:1>:-<NUM_LIT:1>] = ( ((xind[<NUM_LIT:1>:-<NUM_LIT:1>] - x[ind-<NUM_LIT:1>]) / (x[ind] - x[ind-<NUM_LIT:1>]))<EOL>* (y0[ind] - y1[ind-<NUM_LIT:1>]) + y1[ind-<NUM_LIT:1>])<EOL>lut[<NUM_LIT:0>] = y1[<NUM_LIT:0>]<EOL>lut[-<NUM_LIT:1>] = y0[-<NUM_LIT:1>]<EOL>np.clip(lut, <NUM_LIT:0.0>, <NUM_LIT:1.0>)<EOL>return lut<EOL>

Create an *N* -element 1-d lookup table

    *data* represented by a list of x,y0,y1 mapping correspondences.
    Each element in this list represents how a value between 0 and 1
    (inclusive) represented by x is mapped to a corresponding value
    between 0 and 1 (inclusive). The two values of y are to allow
    for discontinuous mapping functions (say as might be found in a
    sawtooth) where y0 represents the value of y for values of x
    <= to that given, and y1 is the value to be used for x > than
    that given). The list must start with x=0, end with x=1, and
    all values of x must be in increasing order. Values between
    the given mapping points are determined by simple linear interpolation.

    The function returns an array "result" where ``result[x*(N-1)]``
    gives the closest value for values of x between 0 and 1.


try: return self.cache[arg]<EOL>except KeyError: pass<EOL>except TypeError: <EOL><INDENT>arg = tuple(arg)<EOL>try: return self.cache[arg]<EOL>except KeyError: pass<EOL>except TypeError:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>% (str(arg),))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if cbook.is_string_like(arg):<EOL><INDENT>color = self.colors.get(arg, None)<EOL>if color is None:<EOL><INDENT>str1 = cnames.get(arg, arg)<EOL>if str1.startswith('<STR_LIT:#>'):<EOL><INDENT>color = hex2color(str1)<EOL><DEDENT>else:<EOL><INDENT>fl = float(arg)<EOL>if fl < <NUM_LIT:0> or fl > <NUM_LIT:1>:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>color = tuple([fl]*<NUM_LIT:3>)<EOL><DEDENT><DEDENT><DEDENT>elif cbook.iterable(arg):<EOL><INDENT>if len(arg) > <NUM_LIT:4> or len(arg) < <NUM_LIT:3>:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'%len(arg))<EOL><DEDENT>color = tuple(arg[:<NUM_LIT:3>])<EOL>if [x for x in color if (float(x) < <NUM_LIT:0>) or  (x > <NUM_LIT:1>)]:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>self.cache[arg] = color<EOL><DEDENT>except (KeyError, ValueError, TypeError) as exc:<EOL><INDENT>raise ValueError('<STR_LIT>' % (str(arg), exc))<EOL><DEDENT>return color<EOL>

Returns an *RGB* tuple of three floats from 0-1.

*arg* can be an *RGB* or *RGBA* sequence or a string in any of
several forms:

    1) a letter from the set 'rgbcmykw'
    2) a hex color string, like '#00FFFF'
    3) a standard name, like 'aqua'
    4) a float, like '0.4', indicating gray on a 0-1 scale

if *arg* is *RGBA*, the *A* will simply be discarded.


try:<EOL><INDENT>if not cbook.is_string_like(arg) and cbook.iterable(arg):<EOL><INDENT>if len(arg) == <NUM_LIT:4>:<EOL><INDENT>if [x for x in arg if (float(x) < <NUM_LIT:0>) or  (x > <NUM_LIT:1>)]:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if alpha is None:<EOL><INDENT>return tuple(arg)<EOL><DEDENT>if alpha < <NUM_LIT:0.0> or alpha > <NUM_LIT:1.0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return arg[<NUM_LIT:0>], arg[<NUM_LIT:1>], arg[<NUM_LIT:2>], arg[<NUM_LIT:3>] * alpha<EOL><DEDENT>r,g,b = arg[:<NUM_LIT:3>]<EOL>if [x for x in (r,g,b) if (float(x) < <NUM_LIT:0>) or  (x > <NUM_LIT:1>)]:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>r,g,b = self.to_rgb(arg)<EOL><DEDENT>if alpha is None:<EOL><INDENT>alpha = <NUM_LIT:1.0><EOL><DEDENT>return r,g,b,alpha<EOL><DEDENT>except (TypeError, ValueError) as exc:<EOL><INDENT>raise ValueError('<STR_LIT>' % (str(arg), exc))<EOL><DEDENT>

Returns an *RGBA* tuple of four floats from 0-1.

For acceptable values of *arg*, see :meth:`to_rgb`.
If *arg* is an *RGBA* sequence and *alpha* is not *None*,
*alpha* will replace the original *A*.


try:<EOL><INDENT>if c.lower() == '<STR_LIT:none>':<EOL><INDENT>return np.zeros((<NUM_LIT:0>,<NUM_LIT:4>), dtype=np.float_)<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>if len(c) == <NUM_LIT:0>:<EOL><INDENT>return np.zeros((<NUM_LIT:0>,<NUM_LIT:4>), dtype=np.float_)<EOL><DEDENT>try:<EOL><INDENT>result = np.array([self.to_rgba(c, alpha)], dtype=np.float_)<EOL><DEDENT>except ValueError:<EOL><INDENT>if isinstance(c, np.ndarray):<EOL><INDENT>if c.ndim != <NUM_LIT:2> and c.dtype.kind not in '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>result = np.zeros((len(c), <NUM_LIT:4>))<EOL>for i, cc in enumerate(c):<EOL><INDENT>result[i] = self.to_rgba(cc, alpha)  <EOL><DEDENT><DEDENT>return np.asarray(result, np.float_)<EOL>

Returns a numpy array of *RGBA* tuples.

Accepts a single mpl color spec or a sequence of specs.

Special case to handle "no color": if *c* is "none" (case-insensitive),
then an empty array will be returned.  Same for an empty list.


self.name = name<EOL>self.N = N<EOL>self._rgba_bad = (<NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:0.0>) <EOL>self._rgba_under = None<EOL>self._rgba_over = None<EOL>self._i_under = N<EOL>self._i_over = N+<NUM_LIT:1><EOL>self._i_bad = N+<NUM_LIT:2><EOL>self._isinit = False<EOL>

Public class attributes:
    :attr:`N` : number of rgb quantization levels
    :attr:`name` : name of colormap


def __call__(self, X, alpha=<NUM_LIT:1.0>, bytes=False):

if not self._isinit: self._init()<EOL>alpha = min(alpha, <NUM_LIT:1.0>) <EOL>alpha = max(alpha, <NUM_LIT:0.0>)<EOL>self._lut[:-<NUM_LIT:3>, -<NUM_LIT:1>] = alpha<EOL>mask_bad = None<EOL>if not cbook.iterable(X):<EOL><INDENT>vtype = '<STR_LIT>'<EOL>xa = np.array([X])<EOL><DEDENT>else:<EOL><INDENT>vtype = '<STR_LIT>'<EOL>xma = ma.asarray(X)<EOL>xa = xma.filled(<NUM_LIT:0>)<EOL>mask_bad = ma.getmask(xma)<EOL><DEDENT>if xa.dtype.char in np.typecodes['<STR_LIT>']:<EOL><INDENT>np.putmask(xa, xa==<NUM_LIT:1.0>, <NUM_LIT>) <EOL>if NP_CLIP_OUT:<EOL><INDENT>np.clip(xa * self.N, -<NUM_LIT:1>, self.N, out=xa)<EOL><DEDENT>else:<EOL><INDENT>xa = np.clip(xa * self.N, -<NUM_LIT:1>, self.N)<EOL><DEDENT>xa = xa.astype(int)<EOL><DEDENT>np.putmask(xa, xa>self.N-<NUM_LIT:1>, self._i_over)<EOL>np.putmask(xa, xa<<NUM_LIT:0>, self._i_under)<EOL>if mask_bad is not None and mask_bad.shape == xa.shape:<EOL><INDENT>np.putmask(xa, mask_bad, self._i_bad)<EOL><DEDENT>if bytes:<EOL><INDENT>lut = (self._lut * <NUM_LIT:255>).astype(np.uint8)<EOL><DEDENT>else:<EOL><INDENT>lut = self._lut<EOL><DEDENT>rgba = np.empty(shape=xa.shape+(<NUM_LIT:4>,), dtype=lut.dtype)<EOL>lut.take(xa, axis=<NUM_LIT:0>, mode='<STR_LIT>', out=rgba)<EOL>if vtype == '<STR_LIT>':<EOL><INDENT>rgba = tuple(rgba[<NUM_LIT:0>,:])<EOL><DEDENT>return rgba<EOL>

*X* is either a scalar or an array (of any dimension).
If scalar, a tuple of rgba values is returned, otherwise
an array with the new shape = oldshape+(4,). If the X-values
are integers, then they are used as indices into the array.
If they are floating point, then they must be in the
interval (0.0, 1.0).
Alpha must be a scalar.
If bytes is False, the rgba values will be floats on a
0-1 scale; if True, they will be uint8, 0-255.


def set_bad(self, color = '<STR_LIT:k>', alpha = <NUM_LIT:1.0>):

self._rgba_bad = colorConverter.to_rgba(color, alpha)<EOL>if self._isinit: self._set_extremes()<EOL>


def set_under(self, color = '<STR_LIT:k>', alpha = <NUM_LIT:1.0>):

self._rgba_under = colorConverter.to_rgba(color, alpha)<EOL>if self._isinit: self._set_extremes()<EOL>

Set color to be used for low out-of-range values.
           Requires norm.clip = False


def set_over(self, color = '<STR_LIT:k>', alpha = <NUM_LIT:1.0>):

self._rgba_over = colorConverter.to_rgba(color, alpha)<EOL>if self._isinit: self._set_extremes()<EOL>

Set color to be used for high out-of-range values.
           Requires norm.clip = False


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


def __init__(self, name, segmentdata, N=<NUM_LIT>):

self.monochrome = False  <EOL>Colormap.__init__(self, name, N)<EOL>self._segmentdata = segmentdata<EOL>

Create color map from linear mapping segments

        segmentdata argument is a dictionary with a red, green and blue
        entries. Each entry should be a list of *x*, *y0*, *y1* tuples,
        forming rows in a table.

        Example: suppose you want red to increase from 0 to 1 over
        the bottom half, green to do the same over the middle half,
        and blue over the top half.  Then you would use::

            cdict = {'red':   [(0.0,  0.0, 0.0),
                               (0.5,  1.0, 1.0),
                               (1.0,  1.0, 1.0)],

                     'green': [(0.0,  0.0, 0.0),
                               (0.25, 0.0, 0.0),
                               (0.75, 1.0, 1.0),
                               (1.0,  1.0, 1.0)],

                     'blue':  [(0.0,  0.0, 0.0),
                               (0.5,  0.0, 0.0),
                               (1.0,  1.0, 1.0)]}

        Each row in the table for a given color is a sequence of
        *x*, *y0*, *y1* tuples.  In each sequence, *x* must increase
        monotonically from 0 to 1.  For any input value *z* falling
        between *x[i]* and *x[i+1]*, the output value of a given color
        will be linearly interpolated between *y1[i]* and *y0[i+1]*::

            row i:   x  y0  y1
                           /
                          /
            row i+1: x  y0  y1

        Hence y0 in the first row and y1 in the last row are never used.

        .. seealso::
            :func:`makeMappingArray`


def __init__(self, colors, name = '<STR_LIT>', N = None):

self.colors = colors<EOL>self.monochrome = False  <EOL>if N is None:<EOL><INDENT>N = len(self.colors)<EOL><DEDENT>else:<EOL><INDENT>if cbook.is_string_like(self.colors):<EOL><INDENT>self.colors = [self.colors] * N<EOL>self.monochrome = True<EOL><DEDENT>elif cbook.iterable(self.colors):<EOL><INDENT>self.colors = list(self.colors) <EOL>if len(self.colors) == <NUM_LIT:1>:<EOL><INDENT>self.monochrome = True<EOL><DEDENT>if len(self.colors) < N:<EOL><INDENT>self.colors = list(self.colors) * N<EOL><DEDENT>del(self.colors[N:])<EOL><DEDENT>else:<EOL><INDENT>try: gray = float(self.colors)<EOL>except TypeError: pass<EOL>else:  self.colors = [gray] * N<EOL>self.monochrome = True<EOL><DEDENT><DEDENT>Colormap.__init__(self, name, N)<EOL>

Make a colormap from a list of colors.

*colors*
    a list of matplotlib color specifications,
    or an equivalent Nx3 floating point array (*N* rgb values)
*name*
    a string to identify the colormap
*N*
    the number of entries in the map.  The default is *None*,
    in which case there is one colormap entry for each
    element in the list of colors.  If::

        N < len(colors)

    the list will be truncated at *N*.  If::

        N > len(colors)

    the list will be extended by repetition.


def __init__(self, vmin=None, vmax=None, clip=False):

self.vmin = vmin<EOL>self.vmax = vmax<EOL>self.clip = clip<EOL>

If *vmin* or *vmax* is not given, they are taken from the input's
minimum and maximum value respectively.  If *clip* is *True* and
the given value falls outside the range, the returned value
will be 0 or 1, whichever is closer. Returns 0 if::

    vmin==vmax

Works with scalars or arrays, including masked arrays.  If
*clip* is *True*, masked values are set to 1; otherwise they
remain masked.  Clipping silently defeats the purpose of setting
the over, under, and masked colors in the colormap, so it is
likely to lead to surprises; therefore the default is
*clip* = *False*.


self.vmin = ma.minimum(A)<EOL>self.vmax = ma.maximum(A)<EOL>


if self.vmin is None: self.vmin = ma.minimum(A)<EOL>if self.vmax is None: self.vmax = ma.maximum(A)<EOL>


return (self.vmin is not None and self.vmax is not None)<EOL>


def __init__(self, boundaries, ncolors, clip=False):

self.clip = clip<EOL>self.vmin = boundaries[<NUM_LIT:0>]<EOL>self.vmax = boundaries[-<NUM_LIT:1>]<EOL>self.boundaries = np.asarray(boundaries)<EOL>self.N = len(self.boundaries)<EOL>self.Ncmap = ncolors<EOL>if self.N-<NUM_LIT:1> == self.Ncmap:<EOL><INDENT>self._interp = False<EOL><DEDENT>else:<EOL><INDENT>self._interp = True<EOL><DEDENT>

*boundaries*
    a monotonically increasing sequence
*ncolors*
    number of colors in the colormap to be used

If::

    b[i] <= v < b[i+1]

then v is mapped to color j;
as i varies from 0 to len(boundaries)-2,
j goes from 0 to ncolors-1.

Out-of-range values are mapped to -1 if low and ncolors
if high; these are converted to valid indices by
:meth:`Colormap.__call__` .


def _get_packed_offsets(wd_list, total, sep, mode="<STR_LIT>"):

w_list, d_list = zip(*wd_list)<EOL>if mode == "<STR_LIT>":<EOL><INDENT>offsets_ = np.add.accumulate([<NUM_LIT:0>]+[w + sep for w in w_list])<EOL>offsets = offsets_[:-<NUM_LIT:1>]<EOL>if total is None:<EOL><INDENT>total = offsets_[-<NUM_LIT:1>] - sep<EOL><DEDENT>return total, offsets<EOL><DEDENT>elif mode == "<STR_LIT>":<EOL><INDENT>sep = (total - sum(w_list))/(len(w_list)-<NUM_LIT:1.>)<EOL>offsets_ = np.add.accumulate([<NUM_LIT:0>]+[w + sep for w in w_list])<EOL>offsets = offsets_[:-<NUM_LIT:1>]<EOL>return total, offsets<EOL><DEDENT>elif mode == "<STR_LIT>":<EOL><INDENT>maxh = max(w_list)<EOL>if total is None:<EOL><INDENT>total = (maxh+sep)*len(w_list)<EOL><DEDENT>else:<EOL><INDENT>sep = float(total)/(len(w_list)) - maxh<EOL><DEDENT>offsets = np.array([(maxh+sep)*i for i in range(len(w_list))])<EOL>return total, offsets<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % (mode,))<EOL><DEDENT>

Geiven a list of (width, xdescent) of each boxes, calculate the
total width and the x-offset positions of each items according to
*mode*. xdescent is analagous to the usual descent, but along the
x-direction. xdescent values are currently ignored.

*wd_list* : list of (width, xdescent) of boxes to be packed.
*sep* : spacing between boxes
*total* : Intended total length. None if not used.
*mode* : packing mode. 'fixed', 'expand', or 'equal'.


def _get_aligned_offsets(hd_list, height, align="<STR_LIT>"):

if height is None:<EOL><INDENT>height = max([h for h, d in hd_list])<EOL><DEDENT>if align == "<STR_LIT>":<EOL><INDENT>height_descent = max([h-d for h, d in hd_list])<EOL>descent = max([d for h, d in hd_list])<EOL>height = height_descent + descent<EOL>offsets = [<NUM_LIT:0.> for h, d in hd_list]<EOL><DEDENT>elif align in ["<STR_LIT:left>","<STR_LIT>"]:<EOL><INDENT>descent=<NUM_LIT:0.><EOL>offsets = [d for h, d in hd_list]<EOL><DEDENT>elif align in ["<STR_LIT:right>","<STR_LIT>"]:<EOL><INDENT>descent=<NUM_LIT:0.><EOL>offsets = [height-h+d for h, d in hd_list]<EOL><DEDENT>elif align == "<STR_LIT>":<EOL><INDENT>descent=<NUM_LIT:0.><EOL>offsets = [(height-h)*<NUM_LIT>+d for h, d in hd_list]<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % (align,))<EOL><DEDENT>return height, descent, offsets<EOL>

Geiven a list of (height, descent) of each boxes, align the boxes
with *align* and calculate the y-offsets of each boxes.
total width and the offset positions of each items according to
*mode*. xdescent is analagous to the usual descent, but along the
x-direction. xdescent values are currently ignored.

*hd_list* : list of (width, xdescent) of boxes to be aligned.
*sep* : spacing between boxes
*height* : Intended total length. None if not used.
*align* : align mode. 'baseline', 'top', 'bottom', or 'center'.


martist.Artist.set_figure(self, fig)<EOL>for c in self.get_children():<EOL><INDENT>c.set_figure(fig)<EOL><DEDENT>

Set the figure

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


self._offset = xy<EOL>

Set the offset

accepts x, y, tuple, or a callable object.


def get_offset(self, width, height, xdescent, ydescent):

if callable(self._offset):<EOL><INDENT>return self._offset(width, height, xdescent, ydescent)<EOL><DEDENT>else:<EOL><INDENT>return self._offset<EOL><DEDENT>

Get the offset

accepts extent of the box


self.width = width<EOL>


self.height = height<EOL>


return self._children<EOL>


w, h, xd, yd, offsets = self.get_extent_offsets(renderer)<EOL>return w, h, xd, yd<EOL>

Return with, height, xdescent, ydescent of box


w, h, xd, yd, offsets = self.get_extent_offsets(renderer)<EOL>px, py = self.get_offset(w, h, xd, yd)<EOL>return mtransforms.Bbox.from_bounds(px-xd, py-yd, w, h)<EOL>


width, height, xdescent, ydescent, offsets = self.get_extent_offsets(renderer)<EOL>px, py = self.get_offset(width, height, xdescent, ydescent)<EOL>for c, (ox, oy) in zip(self.get_children(), offsets):<EOL><INDENT>c.set_offset((px+ox, py+oy))<EOL>c.draw(renderer)<EOL><DEDENT>bbox_artist(self, renderer, fill=False, props=dict(pad=<NUM_LIT:0.>))<EOL>

Update the location of children if necessary and draw them
to the given *renderer*.


def __init__(self, pad=None, sep=None, width=None, height=None,<EOL>align=None, mode=None,<EOL>children=None):

super(PackerBase, self).__init__()<EOL>self.height = height<EOL>self.width = width<EOL>self.sep = sep<EOL>self.pad = pad<EOL>self.mode = mode<EOL>self.align = align<EOL>self._children = children<EOL>

*pad* : boundary pad
*sep* : spacing between items
*width*, *height* : width and height of the container box.
   calculated if None.
*align* : alignment of boxes
*mode* : packing mode


def __init__(self, pad=None, sep=None, width=None, height=None,<EOL>align="<STR_LIT>", mode="<STR_LIT>",<EOL>children=None):

super(VPacker, self).__init__(pad, sep, width, height,<EOL>align, mode, <EOL>children)<EOL>


whd_list = [c.get_extent(renderer) for c in self.get_children()]<EOL>whd_list = [(w, h, xd, (h-yd)) for w, h, xd, yd in whd_list]<EOL>wd_list = [(w, xd) for w, h, xd, yd in whd_list]<EOL>width, xdescent, xoffsets = _get_aligned_offsets(wd_list,<EOL>self.width,<EOL>self.align)<EOL>pack_list = [(h, yd) for w,h,xd,yd in whd_list]<EOL>height, yoffsets_ = _get_packed_offsets(pack_list, self.height,<EOL>self.sep, self.mode)<EOL>yoffsets = yoffsets_  + [yd for w,h,xd,yd in whd_list]<EOL>ydescent = height - yoffsets[<NUM_LIT:0>]<EOL>yoffsets = height - yoffsets<EOL>yoffsets = yoffsets - ydescent<EOL>return width + <NUM_LIT:2>*self.pad, height + <NUM_LIT:2>*self.pad,xdescent+self.pad, ydescent+self.pad,zip(xoffsets, yoffsets)<EOL>

update offset of childrens and return the extents of the box


def __init__(self, pad=None, sep=None, width=None, height=None, <EOL>align="<STR_LIT>", mode="<STR_LIT>",<EOL>children=None):

super(HPacker, self).__init__(pad, sep, width, height,<EOL>align, mode, children)<EOL>


whd_list = [c.get_extent(renderer) for c in self.get_children()]<EOL>if self.height is None:<EOL><INDENT>height_descent = max([h-yd for w,h,xd,yd in whd_list])  <EOL>ydescent = max([yd for w,h,xd,yd in whd_list])<EOL>height = height_descent + ydescent<EOL><DEDENT>else:<EOL><INDENT>height = self.height - <NUM_LIT:2>*self._pad <EOL><DEDENT>hd_list = [(h, yd) for w, h, xd, yd in whd_list]<EOL>height, ydescent, yoffsets = _get_aligned_offsets(hd_list,<EOL>self.height,<EOL>self.align)<EOL>pack_list = [(w, xd) for w,h,xd,yd in whd_list]<EOL>width, xoffsets_ = _get_packed_offsets(pack_list, self.width,<EOL>self.sep, self.mode)<EOL>xoffsets = xoffsets_  + [xd for w,h,xd,yd in whd_list]<EOL>xdescent=whd_list[<NUM_LIT:0>][<NUM_LIT:2>]<EOL>xoffsets = xoffsets - xdescent<EOL>return width + <NUM_LIT:2>*self.pad, height + <NUM_LIT:2>*self.pad,xdescent + self.pad, ydescent + self.pad,zip(xoffsets, yoffsets)<EOL>


def __init__(self, width, height, xdescent=<NUM_LIT:0.>,<EOL>ydescent=<NUM_LIT:0.>, clip=True):

super(DrawingArea, self).__init__()<EOL>self.width = width<EOL>self.height = height<EOL>self.xdescent = xdescent<EOL>self.ydescent = ydescent<EOL>self.offset_transform = mtransforms.Affine2D()<EOL>self.offset_transform.clear()<EOL>self.offset_transform.translate(<NUM_LIT:0>, <NUM_LIT:0>)<EOL>

*width*, *height* : width and height of the container box.
*xdescent*, *ydescent* : descent of the box in x- and y-direction.


return self.offset_transform<EOL>

Return the :class:`~matplotlib.transforms.Transform` applied
to the children


pass<EOL>


self._offset = xy<EOL>self.offset_transform.clear()<EOL>self.offset_transform.translate(xy[<NUM_LIT:0>], xy[<NUM_LIT:1>])<EOL>

set offset of the container.

Accept : tuple of x,y cooridnate in disokay units.


return self._offset<EOL>


w, h, xd, yd = self.get_extent(renderer)<EOL>ox, oy = self.get_offset() <EOL>return mtransforms.Bbox.from_bounds(ox-xd, oy-yd, w, h)<EOL>


return self.width, self.height, self.xdescent, self.ydescent<EOL>


self._children.append(a)<EOL>a.set_transform(self.get_transform())<EOL>

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


for c in self._children:<EOL><INDENT>c.draw(renderer)<EOL><DEDENT>bbox_artist(self, renderer, fill=False, props=dict(pad=<NUM_LIT:0.>))<EOL>


if textprops is None:<EOL><INDENT>textprops = {}<EOL><DEDENT>if not textprops.has_key("<STR_LIT>"):<EOL><INDENT>textprops["<STR_LIT>"]="<STR_LIT>"<EOL><DEDENT>self._text = mtext.Text(<NUM_LIT:0>, <NUM_LIT:0>, s, **textprops)<EOL>OffsetBox.__init__(self)<EOL>self._children = [self._text]<EOL>self.offset_transform = mtransforms.Affine2D()<EOL>self.offset_transform.clear()<EOL>self.offset_transform.translate(<NUM_LIT:0>, <NUM_LIT:0>)<EOL>self._baseline_transform = mtransforms.Affine2D()<EOL>self._text.set_transform(self.offset_transform+self._baseline_transform)<EOL>self._multilinebaseline = multilinebaseline<EOL>self._minimumdescent = minimumdescent<EOL>

*s* : a string to be displayed.
*textprops* : property dictionary for the text
*multilinebaseline* : If True, baseline for multiline text is
                      adjusted so that it is (approximatedly)
                      center-aligned with singleline text.
*minimumdescent*  : If True, the box has a minimum descent of "p".


self._multilinebaseline = t<EOL>

Set multilinebaseline .

If True, baseline for multiline text is
adjusted so that it is (approximatedly) center-aligned with
singleline text.


return self._multilinebaseline<EOL>


self._minimumdescent = t<EOL>

Set minimumdescent .

If True, extent of the single line text is adjusted so that
it has minimum descent of "p"


return self._minimumdescent<EOL>


self._text.draw(renderer)<EOL>bbox_artist(self, renderer, fill=False, props=dict(pad=<NUM_LIT:0.>))<EOL>


return {'<STR_LIT>': ('<STR_LIT>', '<STR_LIT>'),<EOL>'<STR_LIT>': ('<STR_LIT>', '<STR_LIT>'),<EOL>'<STR_LIT>': ('<STR_LIT>',)}[fontext]<EOL>

Return a list of file extensions extensions that are synonyms for
the given file extension *fileext*.


try:<EOL><INDENT>import winreg<EOL><DEDENT>except ImportError:<EOL><INDENT>pass <EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>user = winreg.OpenKey(winreg.HKEY_CURRENT_USER, MSFolders)<EOL>try:<EOL><INDENT>try:<EOL><INDENT>return winreg.QueryValueEx(user, '<STR_LIT>')[<NUM_LIT:0>]<EOL><DEDENT>except OSError:<EOL><INDENT>pass <EOL><DEDENT><DEDENT>finally:<EOL><INDENT>winreg.CloseKey(user)<EOL><DEDENT><DEDENT>except OSError:<EOL><INDENT>pass <EOL><DEDENT><DEDENT>return os.path.join(os.environ['<STR_LIT>'], '<STR_LIT>')<EOL>

Return the user-specified font directory for Win32.  This is
looked up from the registry key::

  \\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Fonts

If the key is not found, $WINDIR/Fonts will be returned.


import winreg<EOL>if directory is None:<EOL><INDENT>directory = win32FontDirectory()<EOL><DEDENT>fontext = get_fontext_synonyms(fontext)<EOL>key, items = None, {}<EOL>for fontdir in MSFontDirectories:<EOL><INDENT>try:<EOL><INDENT>local = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, fontdir)<EOL><DEDENT>except OSError:<EOL><INDENT>continue<EOL><DEDENT>if not local:<EOL><INDENT>files = []<EOL>for ext in fontext:<EOL><INDENT>files.extend(glob.glob(os.path.join(directory, '<STR_LIT>'+ext)))<EOL><DEDENT>return files<EOL><DEDENT>try:<EOL><INDENT>for j in range(winreg.QueryInfoKey(local)[<NUM_LIT:1>]):<EOL><INDENT>try:<EOL><INDENT>key, direc, any = winreg.EnumValue( local, j)<EOL>if not os.path.dirname(direc):<EOL><INDENT>direc = os.path.join(directory, direc)<EOL><DEDENT>direc = os.path.abspath(direc).lower()<EOL>if os.path.splitext(direc)[<NUM_LIT:1>][<NUM_LIT:1>:] in fontext:<EOL><INDENT>items[direc] = <NUM_LIT:1><EOL><DEDENT><DEDENT>except EnvironmentError:<EOL><INDENT>continue<EOL><DEDENT>except WindowsError:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>return list(items.keys())<EOL><DEDENT>finally:<EOL><INDENT>winreg.CloseKey(local)<EOL><DEDENT><DEDENT>return None<EOL>

Search for fonts in the specified font directory, or use the
system directories if none given.  A list of TrueType font
filenames are returned by default, or AFM fonts if *fontext* ==
'afm'.


fontpaths = []<EOL>def add(arg,directory,files):<EOL><INDENT>fontpaths.append(directory)<EOL><DEDENT>for fontdir in OSXFontDirectories:<EOL><INDENT>try:<EOL><INDENT>if os.path.isdir(fontdir):<EOL><INDENT>os.path.walk(fontdir, add, None)<EOL><DEDENT><DEDENT>except (IOError, OSError, TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return fontpaths<EOL>

Return the system font directories for OS X.  This is done by
starting at the list of hardcoded paths in
:attr:`OSXFontDirectories` and returning all nested directories
within them.


if directory is None:<EOL><INDENT>directory = OSXFontDirectory()<EOL><DEDENT>fontext = get_fontext_synonyms(fontext)<EOL>files = []<EOL>for path in directory:<EOL><INDENT>if fontext is None:<EOL><INDENT>files.extend(glob.glob(os.path.join(path,'<STR_LIT:*>')))<EOL><DEDENT>else:<EOL><INDENT>for ext in fontext:<EOL><INDENT>files.extend(glob.glob(os.path.join(path, '<STR_LIT>'+ext)))<EOL>files.extend(glob.glob(os.path.join(path, '<STR_LIT>'+ext.upper())))<EOL><DEDENT><DEDENT><DEDENT>return files<EOL>

Get list of font files on OS X - ignores font suffix by default.


fontpaths = []<EOL>def add(arg,directory,files):<EOL><INDENT>fontpaths.append(directory)<EOL><DEDENT>for fontdir in X11FontDirectories:<EOL><INDENT>try:<EOL><INDENT>if os.path.isdir(fontdir):<EOL><INDENT>os.path.walk(fontdir, add, None)<EOL><DEDENT><DEDENT>except (IOError, OSError, TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return fontpaths<EOL>

Return the system font directories for X11.  This is done by
starting at the list of hardcoded paths in
:attr:`X11FontDirectories` and returning all nested directories
within them.


try:<EOL><INDENT>import subprocess<EOL><DEDENT>except ImportError:<EOL><INDENT>return {}<EOL><DEDENT>fontext = get_fontext_synonyms(fontext)<EOL>fontfiles = {}<EOL>status, output = subprocess.getstatusoutput("<STR_LIT>")<EOL>if status == <NUM_LIT:0>:<EOL><INDENT>for line in output.split('<STR_LIT:\n>'):<EOL><INDENT>fname = line.split('<STR_LIT::>')[<NUM_LIT:0>]<EOL>if (os.path.splitext(fname)[<NUM_LIT:1>][<NUM_LIT:1>:] in fontext and<EOL>os.path.exists(fname)):<EOL><INDENT>fontfiles[fname] = <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>return fontfiles<EOL>

Grab a list of all the fonts that are being tracked by fontconfig
by making a system call to ``fc-list``.  This is an easy way to
grab all of the fonts the user wants to be made available to
applications, without needing knowing where all of them reside.