tbar = rcParams['<STR_LIT>'] <EOL>rcParams['<STR_LIT>'] = '<STR_LIT:None>'<EOL>if targetfig is None:<EOL><INDENT>manager = get_current_fig_manager()<EOL>targetfig = manager.canvas.figure<EOL><DEDENT>else:<EOL><INDENT>for manager in _pylab_helpers.Gcf._activeQue:<EOL><INDENT>if manager.canvas.figure==targetfig: break<EOL><DEDENT>else: raise RuntimeError('<STR_LIT>')<EOL><DEDENT>toolfig = figure(figsize=(<NUM_LIT:6>,<NUM_LIT:3>))<EOL>toolfig.subplots_adjust(top=<NUM_LIT>)<EOL>ret =  SubplotTool(targetfig, toolfig)<EOL>rcParams['<STR_LIT>'] = tbar<EOL>_pylab_helpers.Gcf.set_active(manager)  <EOL>return ret<EOL>

Launch a subplot tool window for *targetfig* (default gcf).

A :class:`matplotlib.widgets.SubplotTool` instance is returned.


ax = gca()<EOL>if on is None:<EOL><INDENT>on = not ax.get_frame_on()<EOL><DEDENT>ax.set_frame_on(on)<EOL>draw_if_interactive()<EOL>

Turn the axes box on or off according to *on*.

If *on* is *None*, toggle state.


l =  gca().set_title(s, *args, **kwargs)<EOL>draw_if_interactive()<EOL>return l<EOL>

Set the title of the current axis to *s*.

Default font override is::

  override = {'fontsize': 'medium',
              'verticalalignment': 'bottom',
              'horizontalalignment': 'center'}

.. seealso::
   :func:`~matplotlib.pyplot.text`:
       for information on how override and the optional args work.


ax = gca()<EOL>v = ax.axis(*v, **kwargs)<EOL>draw_if_interactive()<EOL>return v<EOL>

Set/Get the axis properties:

  >>> axis()

returns the current axes limits ``[xmin, xmax, ymin, ymax]``.

  >>> axis(v)

sets the min and max of the x and y axes, with
``v = [xmin, xmax, ymin, ymax]``.

  >>> axis('off')

turns off the axis lines and labels.

  >>> axis('equal')

changes limits of *x* or *y* axis so that equal increments of *x*
and *y* have the same length; a circle is circular.

  >>> axis('scaled')

achieves the same result by changing the dimensions of the plot box instead
of the axis data limits.

  >>> axis('tight')

changes *x* and *y* axis limits such that all data is shown. If
all data is already shown, it will move it to the center of the
figure without modifying (*xmax* - *xmin*) or (*ymax* -
*ymin*). Note this is slightly different than in matlab.

  >>> axis('image')

is 'scaled' with the axis limits equal to the data limits.

  >>> axis('auto')

and

  >>> axis('normal')

are deprecated. They restore default behavior; axis limits are automatically
scaled to make the data fit comfortably within the plot box.

if ``len(*v)==0``, you can pass in *xmin*, *xmax*, *ymin*, *ymax*
as kwargs selectively to alter just those limits without changing
the others.

The xmin, xmax, ymin, ymax tuple is returned

.. seealso::
    :func:`xlim`, :func:`ylim`


l =  gca().set_xlabel(s, *args, **kwargs)<EOL>draw_if_interactive()<EOL>return l<EOL>

Set the *x* axis label of the current axis to *s*

Default override is::

  override = {
      'fontsize'            : 'small',
      'verticalalignment'   : 'top',
      'horizontalalignment' : 'center'
      }

.. seealso::
    :func:`~matplotlib.pyplot.text`:
        For information on how override and the optional args work


l = gca().set_ylabel(s, *args, **kwargs)<EOL>draw_if_interactive()<EOL>return l<EOL>

Set the *y* axis label of the current axis to *s*.

Defaults override is::

    override = {
       'fontsize'            : 'small',
       'verticalalignment'   : 'center',
       'horizontalalignment' : 'right',
       'rotation'='vertical' : }

.. seealso::
    :func:`~matplotlib.pyplot.text`:
        For information on how override and the optional args
        work.


ax = gca()<EOL>ret = ax.set_xlim(*args, **kwargs)<EOL>draw_if_interactive()<EOL>return ret<EOL>

Set/Get the xlimits of the current axes::

  xmin, xmax = xlim()   # return the current xlim
  xlim( (xmin, xmax) )  # set the xlim to xmin, xmax
  xlim( xmin, xmax )    # set the xlim to xmin, xmax

If you do not specify args, you can pass the xmin and xmax as
kwargs, eg.::

  xlim(xmax=3) # adjust the max leaving min unchanged
  xlim(xmin=1) # adjust the min leaving max unchanged

The new axis limits are returned as a length 2 tuple.


ax = gca()<EOL>ret = ax.set_ylim(*args, **kwargs)<EOL>draw_if_interactive()<EOL>return ret<EOL>

Set/Get the ylimits of the current axes::

  ymin, ymax = ylim()   # return the current ylim
  ylim( (ymin, ymax) )  # set the ylim to ymin, ymax
  ylim( ymin, ymax )    # set the ylim to ymin, ymax

If you do not specify args, you can pass the *ymin* and *ymax* as
kwargs, eg.::

  ylim(ymax=3) # adjust the max leaving min unchanged
  ylim(ymin=1) # adjust the min leaving max unchanged

The new axis limits are returned as a length 2 tuple.


ax = gca()<EOL>ret = ax.set_xscale(*args, **kwargs)<EOL>draw_if_interactive()<EOL>return ret<EOL>

call signature::

  xscale(scale, **kwargs)

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

Different keywords may be accepted, depending on the scale:

%(scale_docs)s


ax = gca()<EOL>ret = ax.set_yscale(*args, **kwargs)<EOL>draw_if_interactive()<EOL>return ret<EOL>

call signature::

  xscale(scale, **kwargs)

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

Different keywords may be accepted, depending on the scale:

%(scale_docs)s


ax = gca()<EOL>if len(args)==<NUM_LIT:0>:<EOL><INDENT>locs = ax.get_xticks()<EOL>labels = ax.get_xticklabels()<EOL><DEDENT>elif len(args)==<NUM_LIT:1>:<EOL><INDENT>locs = ax.set_xticks(args[<NUM_LIT:0>])<EOL>labels = ax.get_xticklabels()<EOL><DEDENT>elif len(args)==<NUM_LIT:2>:<EOL><INDENT>locs = ax.set_xticks(args[<NUM_LIT:0>])<EOL>labels = ax.set_xticklabels(args[<NUM_LIT:1>], **kwargs)<EOL><DEDENT>else: raise TypeError('<STR_LIT>')<EOL>if len(kwargs):<EOL><INDENT>for l in labels:<EOL><INDENT>l.update(kwargs)<EOL><DEDENT><DEDENT>draw_if_interactive()<EOL>return locs, silent_list('<STR_LIT>', labels)<EOL>

Set/Get the xlimits of the current ticklocs and labels::

  # return locs, labels where locs is an array of tick locations and
  # labels is an array of tick labels.
  locs, labels = xticks()

  # set the locations of the xticks
  xticks( arange(6) )

  # set the locations and labels of the xticks
  xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )

The keyword args, if any, are :class:`~matplotlib.text.Text`
properties.


ax = gca()<EOL>if len(args)==<NUM_LIT:0>:<EOL><INDENT>locs = ax.get_yticks()<EOL>labels = ax.get_yticklabels()<EOL><DEDENT>elif len(args)==<NUM_LIT:1>:<EOL><INDENT>locs = ax.set_yticks(args[<NUM_LIT:0>])<EOL>labels = ax.get_yticklabels()<EOL><DEDENT>elif len(args)==<NUM_LIT:2>:<EOL><INDENT>locs = ax.set_yticks(args[<NUM_LIT:0>])<EOL>labels = ax.set_yticklabels(args[<NUM_LIT:1>], **kwargs)<EOL><DEDENT>else: raise TypeError('<STR_LIT>')<EOL>if len(kwargs):<EOL><INDENT>for l in labels:<EOL><INDENT>l.update(kwargs)<EOL><DEDENT><DEDENT>draw_if_interactive()<EOL>return ( locs,<EOL>silent_list('<STR_LIT>', labels)<EOL>)<EOL>

Set/Get the ylimits of the current ticklocs and labels::

  # return locs, labels where locs is an array of tick locations and
  # labels is an array of tick labels.
  locs, labels = yticks()

  # set the locations of the yticks
  yticks( arange(6) )

  # set the locations and labels of the yticks
  yticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )

The keyword args, if any, are :class:`~matplotlib.text.Text`
properties.


ax = gca()<EOL>if not isinstance(ax, PolarAxes):<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>if len(args)==<NUM_LIT:0>:<EOL><INDENT>lines = ax.yaxis.get_ticklines()<EOL>labels = ax.yaxis.get_ticklabels()<EOL><DEDENT>else:<EOL><INDENT>lines, labels = ax.set_rgrids(*args, **kwargs)<EOL><DEDENT>draw_if_interactive()<EOL>return ( silent_list('<STR_LIT>', lines),<EOL>silent_list('<STR_LIT>', labels) )<EOL>

Set/Get the radial locations of the gridlines and ticklabels on a
polar plot.

call signatures::

  lines, labels = rgrids()
  lines, labels = rgrids(radii, labels=None, angle=22.5, **kwargs)

When called with no arguments, :func:`rgrid` simply returns the
tuple (*lines*, *labels*), where *lines* is an array of radial
gridlines (:class:`~matplotlib.lines.Line2D` instances) and
*labels* is an array of tick labels
(:class:`~matplotlib.text.Text` instances). When called with
arguments, the labels will appear at the specified radial
distances and angles.

*labels*, if not *None*, is a len(*radii*) list of strings of the
labels to use at each angle.

If *labels* is None, the rformatter will be used

Examples::

  # set the locations of the radial gridlines and labels
  lines, labels = rgrids( (0.25, 0.5, 1.0) )

  # set the locations and labels of the radial gridlines and labels
  lines, labels = rgrids( (0.25, 0.5, 1.0), ('Tom', 'Dick', 'Harry' )


ax = gca()<EOL>if not isinstance(ax, PolarAxes):<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>if len(args)==<NUM_LIT:0>:<EOL><INDENT>lines = ax.xaxis.get_ticklines()<EOL>labels = ax.xaxis.get_ticklabels()<EOL><DEDENT>else:<EOL><INDENT>lines, labels = ax.set_thetagrids(*args, **kwargs)<EOL><DEDENT>draw_if_interactive()<EOL>return (silent_list('<STR_LIT>', lines),<EOL>silent_list('<STR_LIT>', labels)<EOL>)<EOL>

Set/Get the theta locations of the gridlines and ticklabels.

If no arguments are passed, return a tuple (*lines*, *labels*)
where *lines* is an array of radial gridlines
(:class:`~matplotlib.lines.Line2D` instances) and *labels* is an
array of tick labels (:class:`~matplotlib.text.Text` instances)::

  lines, labels = thetagrids()

Otherwise the syntax is::

  lines, labels = thetagrids(angles, labels=None, fmt='%d', frac = 1.1)

set the angles at which to place the theta grids (these gridlines
are equal along the theta dimension).

*angles* is in degrees.

*labels*, if not *None*, is a len(angles) list of strings of the
labels to use at each angle.

If *labels* is *None*, the labels will be ``fmt%angle``.

*frac* is the fraction of the polar axes radius at which to place
the label (1 is the edge). Eg. 1.05 is outside the axes and 0.95
is inside the axes.

Return value is a list of tuples (*lines*, *labels*):

  - *lines* are :class:`~matplotlib.lines.Line2D` instances

  - *labels* are :class:`~matplotlib.text.Text` instances.

Note that on input, the *labels* argument is a list of strings,
and on output it is a list of :class:`~matplotlib.text.Text`
instances.

Examples::

  # set the locations of the radial gridlines and labels
  lines, labels = thetagrids( range(45,360,90) )

  # set the locations and labels of the radial gridlines and labels
  lines, labels = thetagrids( range(45,360,90), ('NE', 'NW', 'SW','SE') )


pass<EOL>

Plotting commands
=============== =========================================================
Command         Description
=============== =========================================================
axes            Create a new axes
axis            Set or return the current axis limits
bar             make a bar chart
boxplot         make a box and whiskers chart
cla             clear current axes
clabel          label a contour plot
clf             clear a figure window
close           close a figure window
colorbar        add a colorbar to the current figure
cohere          make a plot of coherence
contour         make a contour plot
contourf        make a filled contour plot
csd             make a plot of cross spectral density
draw            force a redraw of the current figure
errorbar        make an errorbar graph
figlegend       add a legend to the figure
figimage        add an image to the figure, w/o resampling
figtext         add text in figure coords
figure          create or change active figure
fill            make filled polygons
fill_between    make filled polygons
gca             return the current axes
gcf             return the current figure
gci             get the current image, or None
getp            get a handle graphics property
hist            make a histogram
hold            set the hold state on current axes
legend          add a legend to the axes
loglog          a log log plot
imread          load image file into array
imshow          plot image data
matshow         display a matrix in a new figure preserving aspect
pcolor          make a pseudocolor plot
plot            make a line plot
plotfile        plot data from a flat file
psd             make a plot of power spectral density
quiver          make a direction field (arrows) plot
rc              control the default params
savefig         save the current figure
scatter         make a scatter plot
setp            set a handle graphics property
semilogx        log x axis
semilogy        log y axis
show            show the figures
specgram        a spectrogram plot
stem            make a stem plot
subplot         make a subplot (numrows, numcols, axesnum)
table           add a table to the axes
text            add some text at location x,y to the current axes
title           add a title to the current axes
xlabel          add an xlabel to the current axes
ylabel          add a ylabel to the current axes
=============== =========================================================

The following commands will set the default colormap accordingly:

* autumn
* bone
* cool
* copper
* flag
* gray
* hot
* hsv
* jet
* pink
* prism
* spring
* summer
* winter
* spectral


pass<EOL>

This is a do nothing function to provide you with help on how
matplotlib handles colors.

Commands which take color arguments can use several formats to
specify the colors.  For the basic builtin colors, you can use a
single letter

  =====   =======
  Alias   Color
  =====   =======
  'b'     blue
  'g'     green
  'r'     red
  'c'     cyan
  'm'     magenta
  'y'     yellow
  'k'     black
  'w'     white
  =====   =======

For a greater range of colors, you have two options.  You can
specify the color using an html hex string, as in::

  color = '#eeefff'

or you can pass an R,G,B tuple, where each of R,G,B are in the
range [0,1].

You can also use any legal html name for a color, for example::

  color = 'red',
  color = 'burlywood'
  color = 'chartreuse'

The example below creates a subplot with a dark
slate gray background

   subplot(111, axisbg=(0.1843, 0.3098, 0.3098))

Here is an example that creates a pale turqoise title::

  title('Is this the best color?', color='#afeeee')


pass<EOL>

matplotlib provides the following colormaps.

* autumn
* bone
* cool
* copper
* flag
* gray
* hot
* hsv
* jet
* pink
* prism
* spring
* summer
* winter
* spectral

You can set the colormap for an image, pcolor, scatter, etc,
either as a keyword argument::

  imshow(X, cmap=cm.hot)

or post-hoc using the corresponding pylab interface function::

  imshow(X)
  hot()
  jet()

In interactive mode, this will update the colormap allowing you to
see which one works best for your data.


im = gci()<EOL>if im is None:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>im.set_clim(vmin, vmax)<EOL>draw_if_interactive()<EOL>

Set the color limits of the current image

To apply clim to all axes images do::

  clim(0, 0.5)

If either *vmin* or *vmax* is None, the image min/max respectively
will be used for color scaling.

If you want to set the clim of multiple images,
use, for example::

  for im in gca().get_images():
      im.set_clim(0, 0.05)


if fignum is False or fignum is <NUM_LIT:0>:<EOL><INDENT>ax = gca()<EOL><DEDENT>else:<EOL><INDENT>fig = figure(fignum, figsize=figaspect(A))<EOL>ax  = fig.add_axes([<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>])<EOL><DEDENT>im = ax.matshow(A, **kw)<EOL>gci._current = im<EOL>draw_if_interactive()<EOL>return im<EOL>

Display an array as a matrix in a new figure window.

The origin is set at the upper left hand corner and rows (first
dimension of the array) are displayed horizontally.  The aspect
ratio of the figure window is that of the array, unless this would
make an excessively short or narrow figure.

Tick labels for the xaxis are placed on top.

With the exception of fignum, keyword arguments are passed to
:func:`~matplotlib.pyplot.imshow`.

*fignum*: [ None | integer | False ]
  By default, :func:`matshow` creates a new figure window with
  automatic numbering.  If *fignum* is given as an integer, the
  created figure will use this figure number.  Because of how
  :func:`matshow` tries to set the figure aspect ratio to be the
  one of the array, if you provide the number of an already
  existing figure, strange things may happen.

  If *fignum* is *False* or 0, a new figure window will **NOT** be created.


ax = gca(polar=True)<EOL>ret = ax.plot(*args, **kwargs)<EOL>draw_if_interactive()<EOL>return ret<EOL>

call signature::

  polar(theta, r, **kwargs)

Make a polar plot.  Multiple *theta*, *r* arguments are supported,
with format strings, as in :func:`~matplotlib.pyplot.plot`.


def plotfile(fname, cols=(<NUM_LIT:0>,), plotfuncs=None,<EOL>comments='<STR_LIT:#>', skiprows=<NUM_LIT:0>, checkrows=<NUM_LIT:5>, delimiter='<STR_LIT:U+002C>',<EOL>**kwargs):

fig = figure()<EOL>if len(cols)<<NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if plotfuncs is None:<EOL><INDENT>plotfuncs = dict()<EOL><DEDENT>r = mlab.csv2rec(fname, comments=comments,<EOL>skiprows=skiprows, checkrows=checkrows, delimiter=delimiter)<EOL>def getname_val(identifier):<EOL><INDENT>'<STR_LIT>'<EOL>if is_string_like(identifier):<EOL><INDENT>return identifier, r[identifier]<EOL><DEDENT>elif is_numlike(identifier):<EOL><INDENT>name = r.dtype.names[int(identifier)]<EOL>return name, r[name]<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT><DEDENT>xname, x = getname_val(cols[<NUM_LIT:0>])<EOL>if len(cols)==<NUM_LIT:1>:<EOL><INDENT>ax1 = fig.add_subplot(<NUM_LIT:1>,<NUM_LIT:1>,<NUM_LIT:1>)<EOL>funcname = plotfuncs.get(cols[<NUM_LIT:0>], '<STR_LIT>')<EOL>func = getattr(ax1, funcname)<EOL>func(x, **kwargs)<EOL>ax1.set_xlabel(xname)<EOL><DEDENT>else:<EOL><INDENT>N = len(cols)<EOL>for i in range(<NUM_LIT:1>,N):<EOL><INDENT>if i==<NUM_LIT:1>:<EOL><INDENT>ax = ax1 = fig.add_subplot(N-<NUM_LIT:1>,<NUM_LIT:1>,i)<EOL>ax.grid(True)<EOL><DEDENT>else:<EOL><INDENT>ax = fig.add_subplot(N-<NUM_LIT:1>,<NUM_LIT:1>,i, sharex=ax1)<EOL>ax.grid(True)<EOL><DEDENT>yname, y = getname_val(cols[i])<EOL>funcname = plotfuncs.get(cols[i], '<STR_LIT>')<EOL>func = getattr(ax, funcname)<EOL>func(x, y, **kwargs)<EOL>ax.set_ylabel(yname)<EOL>if ax.is_last_row():<EOL><INDENT>ax.set_xlabel(xname)<EOL><DEDENT>else:<EOL><INDENT>ax.set_xlabel('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>if xname=='<STR_LIT:date>':<EOL><INDENT>fig.autofmt_xdate()<EOL><DEDENT>draw_if_interactive()<EOL>

Plot the data in *fname*

*cols* is a sequence of column identifiers to plot.  An identifier
is either an int or a string.  If it is an int, it indicates the
column number.  If it is a string, it indicates the column header.
matplotlib will make column headers lower case, replace spaces with
underscores, and remove all illegal characters; so ``'Adj Close*'``
will have name ``'adj_close'``.

- If len(*cols*) == 1, only that column will be plotted on the *y* axis.

- If len(*cols*) > 1, the first element will be an identifier for
  data for the *x* axis and the remaining elements will be the
  column indexes for multiple subplots

*plotfuncs*, if not *None*, is a dictionary mapping identifier to
an :class:`~matplotlib.axes.Axes` plotting function as a string.
Default is 'plot', other choices are 'semilogy', 'fill', 'bar',
etc.  You must use the same type of identifier in the *cols*
vector as you use in the *plotfuncs* dictionary, eg., integer
column numbers in both or column names in both.

*comments*, *skiprows*, *checkrows*, and *delimiter* are all passed on to
:func:`matplotlib.pylab.csv2rec` to load the data into a record array.

kwargs are passed on to plotting functions.

Example usage::

  # plot the 2nd and 4th column against the 1st in two subplots
  plotfile(fname, (0,1,3))

  # plot using column names; specify an alternate plot type for volume
  plotfile(fname, ('date', 'volume', 'adj_close'), plotfuncs={'volume': 'semilogy'})


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.autumn)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to autumn and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.bone)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to bone and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.cool)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to cool and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.copper)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to copper and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.flag)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to flag and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.gray)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to gray and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.hot)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to hot and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.hsv)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to hsv and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.jet)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to jet and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.pink)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to pink and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.prism)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to prism and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.spring)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to spring and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.summer)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to summer and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.winter)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to winter and apply to current image if any.
See help(colormaps) for more information


rc('<STR_LIT:image>', cmap='<STR_LIT>')<EOL>im = gci()<EOL>if im is not None:<EOL><INDENT>im.set_cmap(cm.spectral)<EOL><DEDENT>draw_if_interactive()<EOL>

set the default colormap to spectral and apply to current image if any.
See help(colormaps) for more information


from transforms import Bbox<EOL>if len(args[<NUM_LIT:1>]) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return Bbox.from_extents(*_get_path_collection_extents(*args))<EOL>

Given a sequence of :class:`Path` objects, returns the bounding
box that encapsulates all of them.


def __init__(self, vertices, codes=None):

if ma.isMaskedArray(vertices):<EOL><INDENT>vertices = vertices.astype(np.float_).filled(np.nan)<EOL><DEDENT>else:<EOL><INDENT>vertices = np.asarray(vertices, np.float_)<EOL><DEDENT>if codes is not None:<EOL><INDENT>codes = np.asarray(codes, self.code_type)<EOL>assert codes.ndim == <NUM_LIT:1><EOL>assert len(codes) == len(vertices)<EOL><DEDENT>assert vertices.ndim == <NUM_LIT:2><EOL>assert vertices.shape[<NUM_LIT:1>] == <NUM_LIT:2><EOL>self.should_simplify = (len(vertices) >= <NUM_LIT> and<EOL>(codes is None or np.all(codes <= Path.LINETO)))<EOL>self.has_nonfinite = not np.isfinite(vertices).all()<EOL>self.codes = codes<EOL>self.vertices = vertices<EOL>

Create a new path with the given vertices and codes.

*vertices* is an Nx2 numpy float array, masked array or Python
sequence.

*codes* is an N-length numpy array or Python sequence of type
:attr:`matplotlib.path.Path.code_type`.

These two arrays must have the same length in the first
dimension.

If *codes* is None, *vertices* will be treated as a series of
line segments.

If *vertices* contains masked values, they will be converted
to NaNs which are then handled correctly by the Agg
PathIterator and other consumers of path data, such as
:meth:`iter_segments`.


for p in args:<EOL><INDENT>assert p.codes is None<EOL><DEDENT>lengths = [len(x) for x in args]<EOL>total_length = sum(lengths)<EOL>vertices = np.vstack([x.vertices for x in args])<EOL>vertices.reshape((total_length, <NUM_LIT:2>))<EOL>codes = Path.LINETO * np.ones(total_length)<EOL>i = <NUM_LIT:0><EOL>for length in lengths:<EOL><INDENT>codes[i] = Path.MOVETO<EOL>i += length<EOL><DEDENT>return Path(vertices, codes)<EOL>

(staticmethod) Make a compound path from a list of Path
objects.  Only polygons (not curves) are supported.


vertices = self.vertices<EOL>if not len(vertices):<EOL><INDENT>return<EOL><DEDENT>codes        = self.codes<EOL>len_vertices = len(vertices)<EOL>isfinite     = np.isfinite<EOL>NUM_VERTICES = self.NUM_VERTICES<EOL>MOVETO       = self.MOVETO<EOL>LINETO       = self.LINETO<EOL>CLOSEPOLY    = self.CLOSEPOLY<EOL>STOP         = self.STOP<EOL>if simplify is not None and self.should_simplify:<EOL><INDENT>polygons = self.to_polygons(None, *simplify)<EOL>for vertices in polygons:<EOL><INDENT>yield vertices[<NUM_LIT:0>], MOVETO<EOL>for v in vertices[<NUM_LIT:1>:]:<EOL><INDENT>yield v, LINETO<EOL><DEDENT><DEDENT><DEDENT>elif codes is None:<EOL><INDENT>if self.has_nonfinite:<EOL><INDENT>next_code = MOVETO<EOL>for v in vertices:<EOL><INDENT>if np.isfinite(v).all():<EOL><INDENT>yield v, next_code<EOL>next_code = LINETO<EOL><DEDENT>else:<EOL><INDENT>next_code = MOVETO<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>yield vertices[<NUM_LIT:0>], MOVETO<EOL>for v in vertices[<NUM_LIT:1>:]:<EOL><INDENT>yield v, LINETO<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>i = <NUM_LIT:0><EOL>was_nan = False<EOL>while i < len_vertices:<EOL><INDENT>code = codes[i]<EOL>if code == CLOSEPOLY:<EOL><INDENT>yield [], code<EOL>i += <NUM_LIT:1><EOL><DEDENT>elif code == STOP:<EOL><INDENT>return<EOL><DEDENT>else:<EOL><INDENT>num_vertices = NUM_VERTICES[int(code)]<EOL>curr_vertices = vertices[i:i+num_vertices].flatten()<EOL>if not isfinite(curr_vertices).all():<EOL><INDENT>was_nan = True<EOL><DEDENT>elif was_nan:<EOL><INDENT>yield curr_vertices[-<NUM_LIT:2>:], MOVETO<EOL>was_nan = False<EOL><DEDENT>else:<EOL><INDENT>yield curr_vertices, code<EOL><DEDENT>i += num_vertices<EOL><DEDENT><DEDENT><DEDENT>

Iterates over all of the curve segments in the path.  Each
iteration returns a 2-tuple (*vertices*, *code*), where
*vertices* is a sequence of 1 - 3 coordinate pairs, and *code* is
one of the :class:`Path` codes.

If *simplify* is provided, it must be a tuple (*width*,
*height*) defining the size of the figure, in native units
(e.g. pixels or points).  Simplification implies both removing
adjacent line segments that are very close to parallel, and
removing line segments outside of the figure.  The path will
be simplified *only* if :attr:`should_simplify` is True, which
is determined in the constructor by this criteria:

   - No curves
   - More than 128 vertices


return Path(transform.transform(self.vertices), self.codes)<EOL>

Return a transformed copy of the path.

.. seealso::
    :class:`matplotlib.transforms.TransformedPath`:
        A specialized path class that will cache the
        transformed result and automatically update when the
        transform changes.


def contains_point(self, point, transform=None):

if transform is not None:<EOL><INDENT>transform = transform.frozen()<EOL><DEDENT>return point_in_path(point[<NUM_LIT:0>], point[<NUM_LIT:1>], self, transform)<EOL>

Returns *True* if the path contains the given point.

If *transform* is not *None*, the path will be transformed
before performing the test.


def contains_path(self, path, transform=None):

if transform is not None:<EOL><INDENT>transform = transform.frozen()<EOL><DEDENT>return path_in_path(self, None, path, transform)<EOL>

Returns *True* if this path completely contains the given path.

If *transform* is not *None*, the path will be transformed
before performing the test.


from transforms import Bbox<EOL>if transform is not None:<EOL><INDENT>transform = transform.frozen()<EOL><DEDENT>return Bbox(get_path_extents(self, transform))<EOL>

Returns the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the
path.

Unlike computing the extents on the *vertices* alone, this
algorithm will take into account the curves and deal with
control points appropriately.


def intersects_path(self, other, filled=True):

return path_intersects_path(self, other, filled)<EOL>

Returns *True* if this path intersects another given path.

*filled*, when True, treats the paths as if they were filled.
That is, if one path completely encloses the other,
:meth:`intersects_path` will return True.


def intersects_bbox(self, bbox, filled=True):

from transforms import BboxTransformTo<EOL>rectangle = self.unit_rectangle().transformed(<EOL>BboxTransformTo(bbox))<EOL>result = self.intersects_path(rectangle, filled)<EOL>return result<EOL>

Returns *True* if this path intersects a given
:class:`~matplotlib.transforms.Bbox`.

*filled*, when True, treats the path as if it was filled.
That is, if one path completely encloses the other,
:meth:`intersects_path` will return True.


vertices = simple_linear_interpolation(self.vertices, steps)<EOL>codes = self.codes<EOL>if codes is not None:<EOL><INDENT>new_codes = Path.LINETO * np.ones(((len(codes) - <NUM_LIT:1>) * steps + <NUM_LIT:1>, ))<EOL>new_codes[<NUM_LIT:0>::steps] = codes<EOL><DEDENT>else:<EOL><INDENT>new_codes = None<EOL><DEDENT>return Path(vertices, new_codes)<EOL>

Returns a new path resampled to length N x steps.  Does not
currently handle interpolating curves.


def to_polygons(self, transform=None, width=<NUM_LIT:0>, height=<NUM_LIT:0>):

if len(self.vertices) == <NUM_LIT:0>:<EOL><INDENT>return []<EOL><DEDENT>if transform is not None:<EOL><INDENT>transform = transform.frozen()<EOL><DEDENT>if self.codes is None and (width == <NUM_LIT:0> or height == <NUM_LIT:0>):<EOL><INDENT>if transform is None:<EOL><INDENT>return [self.vertices]<EOL><DEDENT>else:<EOL><INDENT>return [transform.transform(self.vertices)]<EOL><DEDENT><DEDENT>return convert_path_to_polygons(self, transform, width, height)<EOL>

Convert this path to a list of polygons.  Each polygon is an
Nx2 array of vertices.  In other words, each polygon has no
``MOVETO`` instructions or curves.  This is useful for
displaying in backends that do not support compound paths or
Bezier curves, such as GDK.

If *width* and *height* are both non-zero then the lines will
be simplified so that vertices outside of (0, 0), (width,
height) will be clipped.


if cls._unit_rectangle is None:<EOL><INDENT>cls._unit_rectangle =Path([[<NUM_LIT:0.0>, <NUM_LIT:0.0>], [<NUM_LIT:1.0>, <NUM_LIT:0.0>], [<NUM_LIT:1.0>, <NUM_LIT:1.0>], [<NUM_LIT:0.0>, <NUM_LIT:1.0>], [<NUM_LIT:0.0>, <NUM_LIT:0.0>]])<EOL><DEDENT>return cls._unit_rectangle<EOL>

(staticmethod) Returns a :class:`Path` of the unit rectangle
from (0, 0) to (1, 1).


if numVertices <= <NUM_LIT:16>:<EOL><INDENT>path = cls._unit_regular_polygons.get(numVertices)<EOL><DEDENT>else:<EOL><INDENT>path = None<EOL><DEDENT>if path is None:<EOL><INDENT>theta = (<NUM_LIT:2>*np.pi/numVertices *<EOL>np.arange(numVertices + <NUM_LIT:1>).reshape((numVertices + <NUM_LIT:1>, <NUM_LIT:1>)))<EOL>theta += np.pi / <NUM_LIT><EOL>verts = np.concatenate((np.cos(theta), np.sin(theta)), <NUM_LIT:1>)<EOL>path = Path(verts)<EOL>cls._unit_regular_polygons[numVertices] = path<EOL><DEDENT>return path<EOL>

(staticmethod) Returns a :class:`Path` for a unit regular
polygon with the given *numVertices* and radius of 1.0,
centered at (0, 0).


def unit_regular_star(cls, numVertices, innerCircle=<NUM_LIT:0.5>):

if numVertices <= <NUM_LIT:16>:<EOL><INDENT>path = cls._unit_regular_stars.get((numVertices, innerCircle))<EOL><DEDENT>else:<EOL><INDENT>path = None<EOL><DEDENT>if path is None:<EOL><INDENT>ns2 = numVertices * <NUM_LIT:2><EOL>theta = (<NUM_LIT:2>*np.pi/ns2 * np.arange(ns2 + <NUM_LIT:1>))<EOL>theta += np.pi / <NUM_LIT><EOL>r = np.ones(ns2 + <NUM_LIT:1>)<EOL>r[<NUM_LIT:1>::<NUM_LIT:2>] = innerCircle<EOL>verts = np.vstack((r*np.cos(theta), r*np.sin(theta))).transpose()<EOL>path = Path(verts)<EOL>cls._unit_regular_polygons[(numVertices, innerCircle)] = path<EOL><DEDENT>return path<EOL>

(staticmethod) Returns a :class:`Path` for a unit regular star
with the given numVertices and radius of 1.0, centered at (0,
0).


return cls.unit_regular_star(numVertices, <NUM_LIT:0.0>)<EOL>

(staticmethod) Returns a :class:`Path` for a unit regular
asterisk with the given numVertices and radius of 1.0,
centered at (0, 0).


if cls._unit_circle is None:<EOL><INDENT>MAGIC = <NUM_LIT><EOL>SQRTHALF = np.sqrt(<NUM_LIT:0.5>)<EOL>MAGIC45 = np.sqrt((MAGIC*MAGIC) / <NUM_LIT>)<EOL>vertices = np.array(<EOL>[[<NUM_LIT:0.0>, -<NUM_LIT:1.0>],<EOL>[MAGIC, -<NUM_LIT:1.0>],<EOL>[SQRTHALF-MAGIC45, -SQRTHALF-MAGIC45],<EOL>[SQRTHALF, -SQRTHALF],<EOL>[SQRTHALF+MAGIC45, -SQRTHALF+MAGIC45],<EOL>[<NUM_LIT:1.0>, -MAGIC],<EOL>[<NUM_LIT:1.0>, <NUM_LIT:0.0>],<EOL>[<NUM_LIT:1.0>, MAGIC],<EOL>[SQRTHALF+MAGIC45, SQRTHALF-MAGIC45],<EOL>[SQRTHALF, SQRTHALF],<EOL>[SQRTHALF-MAGIC45, SQRTHALF+MAGIC45],<EOL>[MAGIC, <NUM_LIT:1.0>],<EOL>[<NUM_LIT:0.0>, <NUM_LIT:1.0>],<EOL>[-MAGIC, <NUM_LIT:1.0>],<EOL>[-SQRTHALF+MAGIC45, SQRTHALF+MAGIC45],<EOL>[-SQRTHALF, SQRTHALF],<EOL>[-SQRTHALF-MAGIC45, SQRTHALF-MAGIC45],<EOL>[-<NUM_LIT:1.0>, MAGIC],<EOL>[-<NUM_LIT:1.0>, <NUM_LIT:0.0>],<EOL>[-<NUM_LIT:1.0>, -MAGIC],<EOL>[-SQRTHALF-MAGIC45, -SQRTHALF+MAGIC45],<EOL>[-SQRTHALF, -SQRTHALF],<EOL>[-SQRTHALF+MAGIC45, -SQRTHALF-MAGIC45],<EOL>[-MAGIC, -<NUM_LIT:1.0>],<EOL>[<NUM_LIT:0.0>, -<NUM_LIT:1.0>],<EOL>[<NUM_LIT:0.0>, -<NUM_LIT:1.0>]],<EOL>np.float_)<EOL>codes = cls.CURVE4 * np.ones(<NUM_LIT>)<EOL>codes[<NUM_LIT:0>] = cls.MOVETO<EOL>codes[-<NUM_LIT:1>] = cls.CLOSEPOLY<EOL>cls._unit_circle = Path(vertices, codes)<EOL><DEDENT>return cls._unit_circle<EOL>

(staticmethod) Returns a :class:`Path` of the unit circle.
The circle is approximated using cubic Bezier curves.  This
uses 8 splines around the circle using the approach presented
here:

  Lancaster, Don.  `Approximating a Circle or an Ellipse Using Four
  Bezier Cubic Splines <http://www.tinaja.com/glib/ellipse4.pdf>`_.


def arc(cls, theta1, theta2, n=None, is_wedge=False):

<EOL>theta1 *= np.pi / <NUM_LIT><EOL>theta2 *= np.pi / <NUM_LIT><EOL>twopi  = np.pi * <NUM_LIT><EOL>halfpi = np.pi * <NUM_LIT:0.5><EOL>eta1 = np.arctan2(np.sin(theta1), np.cos(theta1))<EOL>eta2 = np.arctan2(np.sin(theta2), np.cos(theta2))<EOL>eta2 -= twopi * np.floor((eta2 - eta1) / twopi)<EOL>if (theta2 - theta1 > np.pi) and (eta2 - eta1 < np.pi):<EOL><INDENT>eta2 += twopi<EOL><DEDENT>if n is None:<EOL><INDENT>n = int(<NUM_LIT:2> ** np.ceil((eta2 - eta1) / halfpi))<EOL><DEDENT>if n < <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>deta = (eta2 - eta1) / n<EOL>t = np.tan(<NUM_LIT:0.5> * deta)<EOL>alpha = np.sin(deta) * (np.sqrt(<NUM_LIT> + <NUM_LIT> * t * t) - <NUM_LIT:1>) / <NUM_LIT><EOL>steps = np.linspace(eta1, eta2, n + <NUM_LIT:1>, True)<EOL>cos_eta = np.cos(steps)<EOL>sin_eta = np.sin(steps)<EOL>xA = cos_eta[:-<NUM_LIT:1>]<EOL>yA = sin_eta[:-<NUM_LIT:1>]<EOL>xA_dot = -yA<EOL>yA_dot = xA<EOL>xB = cos_eta[<NUM_LIT:1>:]<EOL>yB = sin_eta[<NUM_LIT:1>:]<EOL>xB_dot = -yB<EOL>yB_dot = xB<EOL>if is_wedge:<EOL><INDENT>length = n * <NUM_LIT:3> + <NUM_LIT:4><EOL>vertices = np.zeros((length, <NUM_LIT:2>), np.float_)<EOL>codes = Path.CURVE4 * np.ones((length, ), Path.code_type)<EOL>vertices[<NUM_LIT:1>] = [xA[<NUM_LIT:0>], yA[<NUM_LIT:0>]]<EOL>codes[<NUM_LIT:0>:<NUM_LIT:2>] = [Path.MOVETO, Path.LINETO]<EOL>codes[-<NUM_LIT:2>:] = [Path.LINETO, Path.CLOSEPOLY]<EOL>vertex_offset = <NUM_LIT:2><EOL>end = length - <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>length = n * <NUM_LIT:3> + <NUM_LIT:1><EOL>vertices = np.zeros((length, <NUM_LIT:2>), np.float_)<EOL>codes = Path.CURVE4 * np.ones((length, ), Path.code_type)<EOL>vertices[<NUM_LIT:0>] = [xA[<NUM_LIT:0>], yA[<NUM_LIT:0>]]<EOL>codes[<NUM_LIT:0>] = Path.MOVETO<EOL>vertex_offset = <NUM_LIT:1><EOL>end = length<EOL><DEDENT>vertices[vertex_offset  :end:<NUM_LIT:3>, <NUM_LIT:0>] = xA + alpha * xA_dot<EOL>vertices[vertex_offset  :end:<NUM_LIT:3>, <NUM_LIT:1>] = yA + alpha * yA_dot<EOL>vertices[vertex_offset+<NUM_LIT:1>:end:<NUM_LIT:3>, <NUM_LIT:0>] = xB - alpha * xB_dot<EOL>vertices[vertex_offset+<NUM_LIT:1>:end:<NUM_LIT:3>, <NUM_LIT:1>] = yB - alpha * yB_dot<EOL>vertices[vertex_offset+<NUM_LIT:2>:end:<NUM_LIT:3>, <NUM_LIT:0>] = xB<EOL>vertices[vertex_offset+<NUM_LIT:2>:end:<NUM_LIT:3>, <NUM_LIT:1>] = yB<EOL>return Path(vertices, codes)<EOL>

(staticmethod) Returns an arc on the unit circle from angle
*theta1* to angle *theta2* (in degrees).

If *n* is provided, it is the number of spline segments to make.
If *n* is not provided, the number of spline segments is
determined based on the delta between *theta1* and *theta2*.

   Masionobe, L.  2003.  `Drawing an elliptical arc using
   polylines, quadratic or cubic Bezier curves
   <http://www.spaceroots.org/documents/ellipse/index.html>`_.


return cls.arc(theta1, theta2, n, True)<EOL>

(staticmethod) Returns a wedge of the unit circle from angle
*theta1* to angle *theta2* (in degrees).

If *n* is provided, it is the number of spline segments to make.
If *n* is not provided, the number of spline segments is
determined based on the delta between *theta1* and *theta2*.


self._process_values()<EOL>self._find_range()<EOL>X, Y = self._mesh()<EOL>C = self._values[:,np.newaxis]<EOL>self._config_axes(X, Y)<EOL>if self.filled:<EOL><INDENT>self._add_solids(X, Y, C)<EOL><DEDENT>self._set_label()<EOL>

Calculate any free parameters based on the current cmap and norm,
and do all the drawing.


ax = self.ax<EOL>ax.set_frame_on(False)<EOL>ax.set_navigate(False)<EOL>xy = self._outline(X, Y)<EOL>ax.update_datalim(xy)<EOL>ax.set_xlim(*ax.dataLim.intervalx)<EOL>ax.set_ylim(*ax.dataLim.intervaly)<EOL>self.outline = lines.Line2D(xy[:, <NUM_LIT:0>], xy[:, <NUM_LIT:1>], color=mpl.rcParams['<STR_LIT>'],<EOL>linewidth=mpl.rcParams['<STR_LIT>'])<EOL>ax.add_artist(self.outline)<EOL>self.outline.set_clip_box(None)<EOL>self.outline.set_clip_path(None)<EOL>c = mpl.rcParams['<STR_LIT>']<EOL>self.patch = patches.Polygon(xy, edgecolor=c,<EOL>facecolor=c,<EOL>linewidth=<NUM_LIT>,<EOL>zorder=-<NUM_LIT:1>)<EOL>ax.add_artist(self.patch)<EOL>ticks, ticklabels, offset_string = self._ticker()<EOL>if self.orientation == '<STR_LIT>':<EOL><INDENT>ax.set_xticks([])<EOL>ax.yaxis.set_label_position('<STR_LIT:right>')<EOL>ax.yaxis.set_ticks_position('<STR_LIT:right>')<EOL>ax.set_yticks(ticks)<EOL>ax.set_yticklabels(ticklabels)<EOL>ax.yaxis.get_major_formatter().set_offset_string(offset_string)<EOL><DEDENT>else:<EOL><INDENT>ax.set_yticks([])<EOL>ax.xaxis.set_label_position('<STR_LIT>')<EOL>ax.set_xticks(ticks)<EOL>ax.set_xticklabels(ticklabels)<EOL>ax.xaxis.get_major_formatter().set_offset_string(offset_string)<EOL><DEDENT>


self._label = label<EOL>self._labelkw = kw<EOL>self._set_label()<EOL>


N = X.shape[<NUM_LIT:0>]<EOL>ii = [<NUM_LIT:0>, <NUM_LIT:1>, N-<NUM_LIT:2>, N-<NUM_LIT:1>, <NUM_LIT:2>*N-<NUM_LIT:1>, <NUM_LIT:2>*N-<NUM_LIT:2>, N+<NUM_LIT:1>, N, <NUM_LIT:0>]<EOL>x = np.take(np.ravel(np.transpose(X)), ii)<EOL>y = np.take(np.ravel(np.transpose(Y)), ii)<EOL>x = x.reshape((len(x), <NUM_LIT:1>))<EOL>y = y.reshape((len(y), <NUM_LIT:1>))<EOL>if self.orientation == '<STR_LIT>':<EOL><INDENT>return np.hstack((y, x))<EOL><DEDENT>return np.hstack((x, y))<EOL>

Return *x*, *y* arrays of colorbar bounding polygon,
taking orientation into account.


N = X.shape[<NUM_LIT:0>]<EOL>if self.orientation == '<STR_LIT>':<EOL><INDENT>return [list(zip(X[i], Y[i])) for i in range(<NUM_LIT:1>, N-<NUM_LIT:1>)]<EOL><DEDENT>else:<EOL><INDENT>return [list(zip(Y[i], X[i])) for i in range(<NUM_LIT:1>, N-<NUM_LIT:1>)]<EOL><DEDENT>

Return the separator line segments; helper for _add_solids.


<EOL>if self.orientation == '<STR_LIT>':<EOL><INDENT>args = (X, Y, C)<EOL><DEDENT>else:<EOL><INDENT>args = (np.transpose(Y), np.transpose(X), np.transpose(C))<EOL><DEDENT>kw = {'<STR_LIT>':self.cmap, '<STR_LIT>':self.norm,<EOL>'<STR_LIT>':'<STR_LIT>', '<STR_LIT>':self.alpha}<EOL>_hold = self.ax.ishold()<EOL>self.ax.hold(True)<EOL>col = self.ax.pcolor(*args, **kw)<EOL>self.ax.hold(_hold)<EOL>self.solids = col<EOL>if self.drawedges:<EOL><INDENT>self.dividers = collections.LineCollection(self._edges(X,Y),<EOL>colors=(mpl.rcParams['<STR_LIT>'],),<EOL>linewidths=(<NUM_LIT:0.5>*mpl.rcParams['<STR_LIT>'],)<EOL>)<EOL>self.ax.add_collection(self.dividers)<EOL><DEDENT>

Draw the colors using :meth:`~matplotlib.axes.Axes.pcolor`;
optionally add separators.


def add_lines(self, levels, colors, linewidths):

N = len(levels)<EOL>dummy, y = self._locate(levels)<EOL>if len(y) != N:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>x = np.array([<NUM_LIT:0.0>, <NUM_LIT:1.0>])<EOL>X, Y = np.meshgrid(x,y)<EOL>if self.orientation == '<STR_LIT>':<EOL><INDENT>xy = [list(zip(X[i], Y[i])) for i in range(N)]<EOL><DEDENT>else:<EOL><INDENT>xy = [list(zip(Y[i], X[i])) for i in range(N)]<EOL><DEDENT>col = collections.LineCollection(xy, linewidths=linewidths)<EOL>self.lines = col<EOL>col.set_color(colors)<EOL>self.ax.add_collection(col)<EOL>


locator = self.locator<EOL>formatter = self.formatter<EOL>if locator is None:<EOL><INDENT>if self.boundaries is None:<EOL><INDENT>if isinstance(self.norm, colors.NoNorm):<EOL><INDENT>nv = len(self._values)<EOL>base = <NUM_LIT:1> + int(nv/<NUM_LIT:10>)<EOL>locator = ticker.IndexLocator(base=base, offset=<NUM_LIT:0>)<EOL><DEDENT>elif isinstance(self.norm, colors.BoundaryNorm):<EOL><INDENT>b = self.norm.boundaries<EOL>locator = ticker.FixedLocator(b, nbins=<NUM_LIT:10>)<EOL><DEDENT>elif isinstance(self.norm, colors.LogNorm):<EOL><INDENT>locator = ticker.LogLocator()<EOL><DEDENT>else:<EOL><INDENT>locator = ticker.MaxNLocator()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>b = self._boundaries[self._inside]<EOL>locator = ticker.FixedLocator(b, nbins=<NUM_LIT:10>)<EOL><DEDENT><DEDENT>if isinstance(self.norm, colors.NoNorm):<EOL><INDENT>intv = self._values[<NUM_LIT:0>], self._values[-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>intv = self.vmin, self.vmax<EOL><DEDENT>locator.create_dummy_axis()<EOL>formatter.create_dummy_axis()<EOL>locator.set_view_interval(*intv)<EOL>locator.set_data_interval(*intv)<EOL>formatter.set_view_interval(*intv)<EOL>formatter.set_data_interval(*intv)<EOL>b = np.array(locator())<EOL>b, ticks = self._locate(b)<EOL>formatter.set_locs(b)<EOL>ticklabels = [formatter(t, i) for i, t in enumerate(b)]<EOL>offset_string = formatter.get_offset()<EOL>return ticks, ticklabels, offset_string<EOL>

Return two sequences: ticks (colorbar data locations)
and ticklabels (strings).


if b is None:<EOL><INDENT>b = self.boundaries<EOL><DEDENT>if b is not None:<EOL><INDENT>self._boundaries = np.asarray(b, dtype=float)<EOL>if self.values is None:<EOL><INDENT>self._values = <NUM_LIT:0.5>*(self._boundaries[:-<NUM_LIT:1>]<EOL>+ self._boundaries[<NUM_LIT:1>:])<EOL>if isinstance(self.norm, colors.NoNorm):<EOL><INDENT>self._values = (self._values + <NUM_LIT>).astype(np.int16)<EOL><DEDENT>return<EOL><DEDENT>self._values = np.array(self.values)<EOL>return<EOL><DEDENT>if self.values is not None:<EOL><INDENT>self._values = np.array(self.values)<EOL>if self.boundaries is None:<EOL><INDENT>b = np.zeros(len(self.values)+<NUM_LIT:1>, '<STR_LIT:d>')<EOL>b[<NUM_LIT:1>:-<NUM_LIT:1>] = <NUM_LIT:0.5>*(self._values[:-<NUM_LIT:1>] - self._values[<NUM_LIT:1>:])<EOL>b[<NUM_LIT:0>] = <NUM_LIT>*b[<NUM_LIT:1>] - b[<NUM_LIT:2>]<EOL>b[-<NUM_LIT:1>] = <NUM_LIT>*b[-<NUM_LIT:2>] - b[-<NUM_LIT:3>]<EOL>self._boundaries = b<EOL>return<EOL><DEDENT>self._boundaries = np.array(self.boundaries)<EOL>return<EOL><DEDENT>if isinstance(self.norm, colors.NoNorm):<EOL><INDENT>b = self._uniform_y(self.cmap.N+<NUM_LIT:1>) * self.cmap.N - <NUM_LIT:0.5><EOL>v = np.zeros((len(b)-<NUM_LIT:1>,), dtype=np.int16)<EOL>v[self._inside] = np.arange(self.cmap.N, dtype=np.int16)<EOL>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>v[<NUM_LIT:0>] = -<NUM_LIT:1><EOL><DEDENT>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>v[-<NUM_LIT:1>] = self.cmap.N<EOL><DEDENT>self._boundaries = b<EOL>self._values = v<EOL>return<EOL><DEDENT>elif isinstance(self.norm, colors.BoundaryNorm):<EOL><INDENT>b = list(self.norm.boundaries)<EOL>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>b = [b[<NUM_LIT:0>]-<NUM_LIT:1>] + b<EOL><DEDENT>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>b = b + [b[-<NUM_LIT:1>] + <NUM_LIT:1>]<EOL><DEDENT>b = np.array(b)<EOL>v = np.zeros((len(b)-<NUM_LIT:1>,), dtype=float)<EOL>bi = self.norm.boundaries<EOL>v[self._inside] = <NUM_LIT:0.5>*(bi[:-<NUM_LIT:1>] + bi[<NUM_LIT:1>:])<EOL>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>v[<NUM_LIT:0>] = b[<NUM_LIT:0>] - <NUM_LIT:1><EOL><DEDENT>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>v[-<NUM_LIT:1>] = b[-<NUM_LIT:1>] + <NUM_LIT:1><EOL><DEDENT>self._boundaries = b<EOL>self._values = v<EOL>return<EOL><DEDENT>else:<EOL><INDENT>if not self.norm.scaled():<EOL><INDENT>self.norm.vmin = <NUM_LIT:0><EOL>self.norm.vmax = <NUM_LIT:1><EOL><DEDENT>b = self.norm.inverse(self._uniform_y(self.cmap.N+<NUM_LIT:1>))<EOL>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>b[<NUM_LIT:0>] = b[<NUM_LIT:0>] - <NUM_LIT:1><EOL><DEDENT>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>b[-<NUM_LIT:1>] = b[-<NUM_LIT:1>] + <NUM_LIT:1><EOL><DEDENT><DEDENT>self._process_values(b)<EOL>

Set the :attr:`_boundaries` and :attr:`_values` attributes
based on the input boundaries and values.  Input boundaries
can be *self.boundaries* or the argument *b*.


b = self._boundaries[self._inside]<EOL>self.vmin = b[<NUM_LIT:0>]<EOL>self.vmax = b[-<NUM_LIT:1>]<EOL>

Set :attr:`vmin` and :attr:`vmax` attributes to the first and
last boundary excluding extended end boundaries.


nb = len(self._boundaries)<EOL>if self.extend == '<STR_LIT>':<EOL><INDENT>nb -= <NUM_LIT:2><EOL><DEDENT>elif self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>nb -= <NUM_LIT:1><EOL><DEDENT>return nb<EOL>

number of boundaries **before** extension of ends


N = self.cmap.N + <NUM_LIT:1><EOL>if self.extend == '<STR_LIT>':<EOL><INDENT>N += <NUM_LIT:2><EOL><DEDENT>elif self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>N += <NUM_LIT:1><EOL><DEDENT>return N<EOL>

Based on the colormap and extend variable, return the
number of boundaries.


if self.extend == '<STR_LIT>':<EOL><INDENT>y = np.linspace(<NUM_LIT:0>, <NUM_LIT:1>, N)<EOL><DEDENT>else:<EOL><INDENT>if self.extend == '<STR_LIT>':<EOL><INDENT>y = np.zeros(N + <NUM_LIT:2>, '<STR_LIT:d>')<EOL>y[<NUM_LIT:0>] = -<NUM_LIT><EOL>y[-<NUM_LIT:1>] = <NUM_LIT><EOL><DEDENT>elif self.extend == '<STR_LIT>':<EOL><INDENT>y = np.zeros(N + <NUM_LIT:1>, '<STR_LIT:d>')<EOL>y[<NUM_LIT:0>] = -<NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>y = np.zeros(N + <NUM_LIT:1>, '<STR_LIT:d>')<EOL>y[-<NUM_LIT:1>] = <NUM_LIT><EOL><DEDENT>y[self._inside] = np.linspace(<NUM_LIT:0>, <NUM_LIT:1>, N)<EOL><DEDENT>return y<EOL>

Return colorbar data coordinates for *N* uniformly
spaced boundaries, plus ends if required.


if isinstance(self.norm, colors.BoundaryNorm):<EOL><INDENT>b = self._boundaries[self._inside]<EOL>y = (self._boundaries - self._boundaries[<NUM_LIT:0>])<EOL>y = y / (self._boundaries[-<NUM_LIT:1>] - self._boundaries[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>y = self.norm(self._boundaries.copy())<EOL><DEDENT>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>y[<NUM_LIT:0>] = -<NUM_LIT><EOL><DEDENT>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>y[-<NUM_LIT:1>] = <NUM_LIT><EOL><DEDENT>yi = y[self._inside]<EOL>norm = colors.Normalize(yi[<NUM_LIT:0>], yi[-<NUM_LIT:1>])<EOL>y[self._inside] = norm(yi)<EOL>return y<EOL>

Return colorbar data coordinates for the boundaries of
a proportional colorbar.


x = np.array([<NUM_LIT:0.0>, <NUM_LIT:1.0>])<EOL>if self.spacing == '<STR_LIT>':<EOL><INDENT>y = self._uniform_y(self._central_N())<EOL><DEDENT>else:<EOL><INDENT>y = self._proportional_y()<EOL><DEDENT>self._y = y<EOL>X, Y = np.meshgrid(x,y)<EOL>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>X[<NUM_LIT:0>,:] = <NUM_LIT:0.5><EOL><DEDENT>if self.extend in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>X[-<NUM_LIT:1>,:] = <NUM_LIT:0.5><EOL><DEDENT>return X, Y<EOL>

Return X,Y, the coordinate arrays for the colorbar pcolormesh.
These are suitable for a vertical colorbar; swapping and
transposition for a horizontal colorbar are done outside
this function.


if isinstance(self.norm, (colors.NoNorm, colors.BoundaryNorm)):<EOL><INDENT>b = self._boundaries<EOL>xn = x<EOL>xout = x<EOL><DEDENT>else:<EOL><INDENT>b = self.norm(self._boundaries, clip=False).filled()<EOL>xn = self.norm(x, clip=False).filled()<EOL>in_cond = (xn > -<NUM_LIT>) & (xn < <NUM_LIT>)<EOL>xn = np.compress(in_cond, xn)<EOL>xout = np.compress(in_cond, x)<EOL><DEDENT>y = self._y<EOL>N = len(b)<EOL>ii = np.minimum(np.searchsorted(b, xn), N-<NUM_LIT:1>)<EOL>i0 = np.maximum(ii - <NUM_LIT:1>, <NUM_LIT:0>)<EOL>db = np.take(b, ii) - np.take(b, i0)<EOL>db = np.where(i0==ii, <NUM_LIT:1.0>, db)<EOL>dy = np.take(y, ii) - np.take(y, i0)<EOL>z = np.take(y, i0) + (xn-np.take(b,i0))*dy/db<EOL>return xout, z<EOL>

Given a possible set of color data values, return the ones
within range, together with their corresponding colorbar
data coordinates.


if not isinstance(CS, contour.ContourSet) or CS.filled:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>tcolors = [c[<NUM_LIT:0>] for c in CS.tcolors]<EOL>tlinewidths = [t[<NUM_LIT:0>] for t in CS.tlinewidths]<EOL>ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths)<EOL>

Add the lines from a non-filled
:class:`~matplotlib.contour.ContourSet` to the colorbar.


<EOL>self.ax.cla()<EOL>self.draw_all()<EOL>if isinstance(self.mappable, contour.ContourSet):<EOL><INDENT>CS = self.mappable<EOL>if not CS.filled:<EOL><INDENT>self.add_lines(CS)<EOL><DEDENT><DEDENT>

Manually change any contour line colors.  This is called
when the image or contour plot to which this colorbar belongs
is changed.


def table(ax,<EOL>cellText=None, cellColours=None,<EOL>cellLoc='<STR_LIT:right>', colWidths=None,<EOL>rowLabels=None, rowColours=None, rowLoc='<STR_LIT:left>',<EOL>colLabels=None, colColours=None, colLoc='<STR_LIT>',<EOL>loc='<STR_LIT>', bbox=None):

<EOL>if cellText is None:<EOL><INDENT>rows = len(cellColours)<EOL>cols = len(cellColours[<NUM_LIT:0>])<EOL>cellText = [['<STR_LIT>'] * rows] * cols<EOL><DEDENT>rows = len(cellText)<EOL>cols = len(cellText[<NUM_LIT:0>])<EOL>for row in cellText:<EOL><INDENT>assert len(row) == cols<EOL><DEDENT>if cellColours is not None:<EOL><INDENT>assert len(cellColours) == rows<EOL>for row in cellColours:<EOL><INDENT>assert len(row) == cols<EOL><DEDENT><DEDENT>else:<EOL><INDENT>cellColours = ['<STR_LIT:w>' * cols] * rows<EOL><DEDENT>if colWidths is None:<EOL><INDENT>colWidths = [<NUM_LIT:1.0>/cols] * cols<EOL><DEDENT>rowLabelWidth = <NUM_LIT:0><EOL>if rowLabels is None:<EOL><INDENT>if rowColours is not None:<EOL><INDENT>rowLabels = ['<STR_LIT>'] * cols<EOL>rowLabelWidth = colWidths[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>elif rowColours is None:<EOL><INDENT>rowColours = '<STR_LIT:w>' * rows<EOL><DEDENT>if rowLabels is not None:<EOL><INDENT>assert len(rowLabels) == rows<EOL><DEDENT>offset = <NUM_LIT:0><EOL>if colLabels is None:<EOL><INDENT>if colColours is not None:<EOL><INDENT>colLabels = ['<STR_LIT>'] * rows<EOL>offset = <NUM_LIT:1><EOL><DEDENT><DEDENT>elif colColours is None:<EOL><INDENT>colColours = '<STR_LIT:w>' * cols<EOL>offset = <NUM_LIT:1><EOL><DEDENT>if rowLabels is not None:<EOL><INDENT>assert len(rowLabels) == rows<EOL><DEDENT>if cellColours is None:<EOL><INDENT>cellColours = ['<STR_LIT:w>' * cols] * rows<EOL><DEDENT>table = Table(ax, loc, bbox)<EOL>height = table._approx_text_height()<EOL>for row in xrange(rows):<EOL><INDENT>for col in xrange(cols):<EOL><INDENT>table.add_cell(row+offset, col,<EOL>width=colWidths[col], height=height,<EOL>text=cellText[row][col],<EOL>facecolor=cellColours[row][col],<EOL>loc=cellLoc)<EOL><DEDENT><DEDENT>if colLabels is not None:<EOL><INDENT>for col in xrange(cols):<EOL><INDENT>table.add_cell(<NUM_LIT:0>, col,<EOL>width=colWidths[col], height=height,<EOL>text=colLabels[col], facecolor=colColours[col],<EOL>loc=colLoc)<EOL><DEDENT><DEDENT>if rowLabels is not None:<EOL><INDENT>for row in xrange(rows):<EOL><INDENT>table.add_cell(row+offset, -<NUM_LIT:1>,<EOL>width=rowLabelWidth or <NUM_LIT>, height=height,<EOL>text=rowLabels[row], facecolor=rowColours[row],<EOL>loc=rowLoc)<EOL><DEDENT>if rowLabelWidth == <NUM_LIT:0>:<EOL><INDENT>table.auto_set_column_width(-<NUM_LIT:1>)<EOL><DEDENT><DEDENT>ax.add_table(table)<EOL>return table<EOL>

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)

Factory function to generate a Table instance.

Thanks to John Gill for providing the class and table.


return self._text<EOL>


return self._text.get_fontsize()<EOL>


fontsize = self.get_fontsize()<EOL>required = self.get_required_width(renderer)<EOL>while fontsize > <NUM_LIT:1> and required > self.get_width():<EOL><INDENT>fontsize -= <NUM_LIT:1><EOL>self.set_fontsize(fontsize)<EOL>required = self.get_required_width(renderer)<EOL><DEDENT>return fontsize<EOL>


bbox = self.get_window_extent(renderer)<EOL>l, b, w, h = bbox.bounds<EOL>self._text.set_verticalalignment('<STR_LIT>')<EOL>y = b + (h / <NUM_LIT>)<EOL>if self._loc == '<STR_LIT>':<EOL><INDENT>self._text.set_horizontalalignment('<STR_LIT>')<EOL>x = l + (w / <NUM_LIT>)<EOL><DEDENT>elif self._loc == '<STR_LIT:left>':<EOL><INDENT>self._text.set_horizontalalignment('<STR_LIT:left>')<EOL>x = l + (w * self.PAD)<EOL><DEDENT>else:<EOL><INDENT>self._text.set_horizontalalignment('<STR_LIT:right>')<EOL>x = l + (w * (<NUM_LIT:1.0> - self.PAD))<EOL><DEDENT>self._text.set_position((x, y))<EOL>

Set text up so it draws in the right place.

        Currently support 'left', 'center' and 'right'


bbox = self._text.get_window_extent(renderer)<EOL>bboxa = bbox.inverse_transformed(self.get_data_transform())<EOL>return bboxa.bounds<EOL>


l,b,w,h = self.get_text_bounds(renderer)<EOL>return w * (<NUM_LIT:1.0> + (<NUM_LIT> * self.PAD))<EOL>


def add_cell(self, row, col, *args, **kwargs):

xy = (<NUM_LIT:0>,<NUM_LIT:0>)<EOL>cell = Cell(xy, *args, **kwargs)<EOL>cell.set_figure(self.figure)<EOL>cell.set_transform(self.get_transform())<EOL>cell.set_clip_on(False)<EOL>self._cells[(row, col)] = cell<EOL>


boxes = [self._cells[pos].get_window_extent(renderer)<EOL>for pos in self._cells.keys()<EOL>if pos[<NUM_LIT:0>] >= <NUM_LIT:0> and pos[<NUM_LIT:1>] >= <NUM_LIT:0>]<EOL>bbox = Bbox.union(boxes)<EOL>return bbox.inverse_transformed(self.get_transform())<EOL>

Get a bbox, in axes co-ordinates for the cells.

        Only include those in the range (0,0) to (maxRow, maxCol)


if callable(self._contains): return self._contains(self,mouseevent)<EOL>if self._cachedRenderer is not None:<EOL><INDENT>boxes = [self._cells[pos].get_window_extent(self._cachedRenderer)<EOL>for pos in self._cells.keys()<EOL>if pos[<NUM_LIT:0>] >= <NUM_LIT:0> and pos[<NUM_LIT:1>] >= <NUM_LIT:0>]<EOL>bbox = bbox_all(boxes)<EOL>return bbox.contains(mouseevent.x,mouseevent.y),{}<EOL><DEDENT>else:<EOL><INDENT>return False,{}<EOL><DEDENT>

Test whether the mouse event occurred in the table.

        Returns T/F, {}


return self._cells.values()<EOL>

Return the Artists contained by the table


boxes = [c.get_window_extent(renderer) for c in self._cells]<EOL>return bbox_all(boxes)<EOL>

Return the bounding box of the table in window coords


<EOL>widths = {}<EOL>heights = {}<EOL>for (row, col), cell in self._cells.iteritems():<EOL><INDENT>height = heights.setdefault(row, <NUM_LIT:0.0>)<EOL>heights[row] = max(height, cell.get_height())<EOL>width = widths.setdefault(col, <NUM_LIT:0.0>)<EOL>widths[col] = max(width, cell.get_width())<EOL><DEDENT>xpos = <NUM_LIT:0><EOL>lefts = {}<EOL>cols = widths.keys()<EOL>cols.sort()<EOL>for col in cols:<EOL><INDENT>lefts[col] = xpos<EOL>xpos += widths[col]<EOL><DEDENT>ypos = <NUM_LIT:0><EOL>bottoms = {}<EOL>rows = heights.keys()<EOL>rows.sort()<EOL>rows.reverse()<EOL>for row in rows:<EOL><INDENT>bottoms[row] = ypos<EOL>ypos += heights[row]<EOL><DEDENT>for (row, col), cell in self._cells.iteritems():<EOL><INDENT>cell.set_x(lefts[col])<EOL>cell.set_y(bottoms[row])<EOL><DEDENT>

Calculate row heights and column widths.

        Position cells accordingly.


def _auto_set_column_width(self, col, renderer):

cells = [key for key in self._cells if key[<NUM_LIT:1>] == col]<EOL>width = <NUM_LIT:0><EOL>for cell in cells:<EOL><INDENT>c = self._cells[cell]<EOL>width = max(c.get_required_width(renderer), width)<EOL><DEDENT>for cell in cells:<EOL><INDENT>self._cells[cell].set_width(width)<EOL><DEDENT>


self._autoFontsize = value<EOL>


for c in self._cells.itervalues():<EOL><INDENT>c.set_width(c.get_width() * xscale)<EOL>c.set_height(c.get_height() * yscale)<EOL><DEDENT>

Scale column widths by xscale and row heights by yscale.


for cell in self._cells.itervalues():<EOL><INDENT>cell.set_fontsize(size)<EOL><DEDENT>

Set the fontsize of the cell text

ACCEPTS: a float in points


for c in self._cells.itervalues():<EOL><INDENT>x, y = c.get_x(), c.get_y()<EOL>c.set_x(x+ox)<EOL>c.set_y(y+oy)<EOL><DEDENT>

Move all the artists by ox,oy (axes coords)


return self._cells<EOL>


def __init__(self, parent, handles, labels,<EOL>loc = None,<EOL>numpoints = None,     <EOL>markerscale = None,   <EOL>scatterpoints = <NUM_LIT:3>,    <EOL>scatteryoffsets=None,<EOL>prop = None,          <EOL>pad = None,           <EOL>labelsep = None,      <EOL>handlelen = None,     <EOL>handletextsep = None, <EOL>axespad = None,       <EOL>borderpad = None,     <EOL>labelspacing=None, <EOL>handlelength=None, <EOL>handletextpad=None, <EOL>borderaxespad=None, <EOL>columnspacing=None, <EOL>ncol=<NUM_LIT:1>, <EOL>mode=None, <EOL>fancybox=None, <EOL>shadow = None,<EOL>):

from matplotlib.axes import Axes     <EOL>from matplotlib.figure import Figure <EOL>Artist.__init__(self)<EOL>if prop is None:<EOL><INDENT>self.prop=FontProperties(size=rcParams["<STR_LIT>"])<EOL><DEDENT>else:<EOL><INDENT>self.prop=prop<EOL><DEDENT>self.fontsize = self.prop.get_size_in_points()<EOL>propnames=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', "<STR_LIT>",<EOL>"<STR_LIT>"]<EOL>localdict = locals()<EOL>for name in propnames:<EOL><INDENT>if localdict[name] is None:<EOL><INDENT>value = rcParams["<STR_LIT>"+name]<EOL><DEDENT>else:<EOL><INDENT>value = localdict[name]<EOL><DEDENT>setattr(self, name, value)<EOL><DEDENT>deprecated_kwds = {"<STR_LIT>":"<STR_LIT>",<EOL>"<STR_LIT>":"<STR_LIT>",<EOL>"<STR_LIT>":"<STR_LIT>",<EOL>"<STR_LIT>":"<STR_LIT>",<EOL>"<STR_LIT>":"<STR_LIT>"}<EOL>bbox = parent.bbox<EOL>axessize_fontsize = min(bbox.width, bbox.height)/self.fontsize<EOL>for k, v in deprecated_kwds.items():<EOL><INDENT>if localdict[k] is not None and localdict[v] is None:<EOL><INDENT>warnings.warn("<STR_LIT>" % (v, k),<EOL>DeprecationWarning)<EOL>setattr(self, v, localdict[k]*axessize_fontsize)<EOL>continue<EOL><DEDENT>if localdict[v] is None:<EOL><INDENT>setattr(self, v, rcParams["<STR_LIT>"+v])<EOL><DEDENT>else:<EOL><INDENT>setattr(self, v, localdict[v])<EOL><DEDENT><DEDENT>del localdict<EOL>self._ncol = ncol<EOL>if self.numpoints <= <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>"% numpoints)<EOL><DEDENT>if scatteryoffsets is None:<EOL><INDENT>self._scatteryoffsets = np.array([<NUM_LIT>/<NUM_LIT>, <NUM_LIT>/<NUM_LIT>, <NUM_LIT>/<NUM_LIT>])<EOL><DEDENT>else:<EOL><INDENT>self._scatteryoffsets = np.asarray(scatteryoffsets)<EOL><DEDENT>reps =  int(self.numpoints / len(self._scatteryoffsets)) + <NUM_LIT:1><EOL>self._scatteryoffsets = np.tile(self._scatteryoffsets, reps)[:self.scatterpoints]<EOL>self._legend_box = None<EOL>if isinstance(parent,Axes):<EOL><INDENT>self.isaxes = True<EOL>self.set_figure(parent.figure)<EOL><DEDENT>elif isinstance(parent,Figure):<EOL><INDENT>self.isaxes = False<EOL>self.set_figure(parent)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>self.parent = parent<EOL>if loc is None:<EOL><INDENT>loc = rcParams["<STR_LIT>"]<EOL>if not self.isaxes and loc in [<NUM_LIT:0>,'<STR_LIT>']:<EOL><INDENT>loc = '<STR_LIT>'<EOL><DEDENT><DEDENT>if is_string_like(loc):<EOL><INDENT>if loc not in self.codes:<EOL><INDENT>if self.isaxes:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (loc, '<STR_LIT>'.join(self.codes.keys())))<EOL>loc = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (loc, '<STR_LIT>'.join(self.codes.keys())))<EOL>loc = <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>loc = self.codes[loc]<EOL><DEDENT><DEDENT>if not self.isaxes and loc == <NUM_LIT:0>:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>loc = <NUM_LIT:1><EOL><DEDENT>self._loc = loc<EOL>self._mode = mode<EOL>self.legendPatch = FancyBboxPatch(<EOL>xy=(<NUM_LIT:0.0>, <NUM_LIT:0.0>), width=<NUM_LIT:1.>, height=<NUM_LIT:1.>,<EOL>facecolor='<STR_LIT:w>', edgecolor='<STR_LIT:k>',<EOL>mutation_scale=self.fontsize,<EOL>snap=True<EOL>)<EOL>if fancybox is None:<EOL><INDENT>fancybox = rcParams["<STR_LIT>"]<EOL><DEDENT>if fancybox == True:<EOL><INDENT>self.legendPatch.set_boxstyle("<STR_LIT>",pad=<NUM_LIT:0>,<EOL>rounding_size=<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>self.legendPatch.set_boxstyle("<STR_LIT>",pad=<NUM_LIT:0>)<EOL><DEDENT>self._set_artist_props(self.legendPatch)<EOL>self._drawFrame = True<EOL>self._init_legend_box(handles, labels)<EOL>self._last_fontsize_points = self.fontsize<EOL>

- *parent* : the artist that contains the legend
        - *handles* : a list of artists (lines, patches) to add to the legend
        - *labels* : a list of strings to label the legend

        Optional keyword arguments:

        ================   ==================================================================
        Keyword            Description
        ================   ==================================================================
        loc                a location code or a tuple of coordinates
        numpoints          the number of points in the legend line
        prop               the font property
        markerscale        the relative size of legend markers vs. original
        fancybox           if True, draw a frame with a round fancybox.  If None, use rc
        shadow             if True, draw a shadow behind legend
        scatteryoffsets    a list of yoffsets for scatter symbols in legend
        borderpad          the fractional whitespace inside the legend border
        labelspacing       the vertical space between the legend entries
        handlelength       the length of the legend handles
        handletextpad      the pad between the legend handle and text
        borderaxespad      the pad between the axes and legend border
        columnspacing      the spacing between columns
        ================   ==================================================================

The dimensions of pad and spacing are given as a fraction of the
fontsize. Values from rcParams will be used if None.


a.set_figure(self.figure)<EOL>for c in self.get_children():<EOL><INDENT>c.set_figure(self.figure)<EOL><DEDENT>a.set_transform(self.get_transform())<EOL>

set the boilerplate props for artists added to axes


def _findoffset_best(self, width, height, xdescent, ydescent, renderer):

ox, oy = self._find_best_position(width, height, renderer)<EOL>return ox+xdescent, oy+ydescent<EOL>

Heper function to locate the legend at its best position


def _findoffset_loc(self, width, height, xdescent, ydescent, renderer):

if iterable(self._loc) and len(self._loc)==<NUM_LIT:2>:<EOL><INDENT>fx, fy = self._loc<EOL>bbox = self.parent.bbox<EOL>x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy<EOL><DEDENT>else:<EOL><INDENT>bbox = Bbox.from_bounds(<NUM_LIT:0>, <NUM_LIT:0>, width, height)<EOL>x, y = self._get_anchored_bbox(self._loc, bbox, self.parent.bbox, renderer)<EOL><DEDENT>return x+xdescent, y+ydescent<EOL>

Heper function to locate the legend using the location code


if not self.get_visible(): return<EOL>self._update_legend_box(renderer)<EOL>renderer.open_group('<STR_LIT>')<EOL>if self._loc == <NUM_LIT:0>:<EOL><INDENT>_findoffset = self._findoffset_best<EOL><DEDENT>else:<EOL><INDENT>_findoffset = self._findoffset_loc<EOL><DEDENT>def findoffset(width, height, xdescent, ydescent):<EOL><INDENT>return _findoffset(width, height, xdescent, ydescent, renderer)<EOL><DEDENT>self._legend_box.set_offset(findoffset)<EOL>fontsize = renderer.points_to_pixels(self.fontsize)<EOL>if self._mode in ["<STR_LIT>"]:<EOL><INDENT>pad = <NUM_LIT:2>*(self.borderaxespad+self.borderpad)*fontsize<EOL>self._legend_box.set_width(self.parent.bbox.width-pad)<EOL><DEDENT>if self._drawFrame:<EOL><INDENT>bbox = self._legend_box.get_window_extent(renderer)<EOL>self.legendPatch.set_bounds(bbox.x0, bbox.y0,<EOL>bbox.width, bbox.height)<EOL>self.legendPatch.set_mutation_scale(fontsize)<EOL>if self.shadow:<EOL><INDENT>shadow = Shadow(self.legendPatch, <NUM_LIT:2>, -<NUM_LIT:2>)<EOL>shadow.draw(renderer)<EOL><DEDENT>self.legendPatch.draw(renderer)<EOL><DEDENT>self._legend_box.draw(renderer)<EOL>renderer.close_group('<STR_LIT>')<EOL>

Draw everything that belongs to the legend


if renderer is None:<EOL><INDENT>return self.fontsize<EOL><DEDENT>else:<EOL><INDENT>return renderer.points_to_pixels(self.fontsize)<EOL><DEDENT>

Return the approximate height of the text. This is used to place
the legend handle.


def _init_legend_box(self, handles, labels):

fontsize = self.fontsize<EOL>text_list = []  <EOL>handle_list = []  <EOL>label_prop = dict(verticalalignment='<STR_LIT>',<EOL>horizontalalignment='<STR_LIT:left>',<EOL>fontproperties=self.prop,<EOL>)<EOL>labelboxes = []<EOL>for l in labels:<EOL><INDENT>textbox = TextArea(l, textprops=label_prop,<EOL>multilinebaseline=True, minimumdescent=True)<EOL>text_list.append(textbox._text)<EOL>labelboxes.append(textbox)<EOL><DEDENT>handleboxes = []<EOL>height = self._approx_text_height() * <NUM_LIT><EOL>descent = <NUM_LIT:0.><EOL>for handle in handles:<EOL><INDENT>if isinstance(handle, RegularPolyCollection):<EOL><INDENT>npoints = self.scatterpoints<EOL><DEDENT>else:<EOL><INDENT>npoints = self.numpoints<EOL><DEDENT>if npoints > <NUM_LIT:1>:<EOL><INDENT>xdata = np.linspace(<NUM_LIT>*fontsize,<EOL>(self.handlelength-<NUM_LIT>)*fontsize,<EOL>npoints)<EOL>xdata_marker = xdata<EOL><DEDENT>elif npoints == <NUM_LIT:1>:<EOL><INDENT>xdata = np.linspace(<NUM_LIT:0>, self.handlelength*fontsize, <NUM_LIT:2>)<EOL>xdata_marker = [<NUM_LIT:0.5>*self.handlelength*fontsize]<EOL><DEDENT>if isinstance(handle, Line2D):<EOL><INDENT>ydata = ((height-descent)/<NUM_LIT>)*np.ones(xdata.shape, float)<EOL>legline = Line2D(xdata, ydata)<EOL>legline.update_from(handle)<EOL>self._set_artist_props(legline) <EOL>legline.set_clip_box(None)<EOL>legline.set_clip_path(None)<EOL>legline.set_drawstyle('<STR_LIT:default>')<EOL>legline.set_marker('<STR_LIT:None>')<EOL>handle_list.append(legline)<EOL>legline_marker = Line2D(xdata_marker, ydata[:len(xdata_marker)])<EOL>legline_marker.update_from(handle)<EOL>self._set_artist_props(legline_marker)<EOL>legline_marker.set_clip_box(None)<EOL>legline_marker.set_clip_path(None)<EOL>legline_marker.set_linestyle('<STR_LIT:None>')<EOL>legline._legmarker = legline_marker<EOL><DEDENT>elif isinstance(handle, Patch):<EOL><INDENT>p = Rectangle(xy=(<NUM_LIT:0.>, <NUM_LIT:0.>),<EOL>width = self.handlelength*fontsize,<EOL>height=(height-descent),<EOL>)<EOL>p.update_from(handle)<EOL>self._set_artist_props(p)<EOL>p.set_clip_box(None)<EOL>p.set_clip_path(None)<EOL>handle_list.append(p)<EOL><DEDENT>elif isinstance(handle, LineCollection):<EOL><INDENT>ydata = ((height-descent)/<NUM_LIT>)*np.ones(xdata.shape, float)<EOL>legline = Line2D(xdata, ydata)<EOL>self._set_artist_props(legline)<EOL>legline.set_clip_box(None)<EOL>legline.set_clip_path(None)<EOL>lw = handle.get_linewidth()[<NUM_LIT:0>]<EOL>dashes = handle.get_dashes()[<NUM_LIT:0>]<EOL>color = handle.get_colors()[<NUM_LIT:0>]<EOL>legline.set_color(color)<EOL>legline.set_linewidth(lw)<EOL>legline.set_dashes(dashes)<EOL>handle_list.append(legline)<EOL><DEDENT>elif isinstance(handle, RegularPolyCollection):<EOL><INDENT>ydata = height*self._scatteryoffsets<EOL>size_max, size_min = max(handle.get_sizes()),min(handle.get_sizes())<EOL>if self.scatterpoints < <NUM_LIT:4>:<EOL><INDENT>sizes = [<NUM_LIT>*(size_max+size_min), size_max,<EOL>size_min]<EOL><DEDENT>else:<EOL><INDENT>sizes = (size_max-size_min)*np.linspace(<NUM_LIT:0>,<NUM_LIT:1>,self.scatterpoints)+size_min<EOL><DEDENT>p = type(handle)(handle.get_numsides(),<EOL>rotation=handle.get_rotation(),<EOL>sizes=sizes,<EOL>offsets=zip(xdata_marker,ydata),<EOL>transOffset=self.get_transform(),<EOL>)<EOL>p.update_from(handle)<EOL>p.set_figure(self.figure)<EOL>p.set_clip_box(None)<EOL>p.set_clip_path(None)<EOL>handle_list.append(p)<EOL><DEDENT>else:<EOL><INDENT>handle_list.append(None)<EOL><DEDENT>handlebox = DrawingArea(width=self.handlelength*fontsize,<EOL>height=height,<EOL>xdescent=<NUM_LIT:0.>, ydescent=descent)<EOL>handle = handle_list[-<NUM_LIT:1>]<EOL>handlebox.add_artist(handle)<EOL>if hasattr(handle, "<STR_LIT>"):<EOL><INDENT>handlebox.add_artist(handle._legmarker)<EOL><DEDENT>handleboxes.append(handlebox)<EOL><DEDENT>nrows, num_largecol = divmod(len(handleboxes), self._ncol)<EOL>num_smallcol = self._ncol-num_largecol<EOL>largecol = safezip(range(<NUM_LIT:0>, num_largecol*(nrows+<NUM_LIT:1>), (nrows+<NUM_LIT:1>)),<EOL>[nrows+<NUM_LIT:1>] * num_largecol)<EOL>smallcol = safezip(range(num_largecol*(nrows+<NUM_LIT:1>), len(handleboxes), nrows),<EOL>[nrows] * num_smallcol)<EOL>handle_label = safezip(handleboxes, labelboxes)<EOL>columnbox = []<EOL>for i0, di in largecol+smallcol:<EOL><INDENT>itemBoxes = [HPacker(pad=<NUM_LIT:0>,<EOL>sep=self.handletextpad*fontsize,<EOL>children=[h, t], align="<STR_LIT>")<EOL>for h, t in handle_label[i0:i0+di]]<EOL>itemBoxes[-<NUM_LIT:1>].get_children()[<NUM_LIT:1>].set_minimumdescent(False)<EOL>columnbox.append(VPacker(pad=<NUM_LIT:0>,<EOL>sep=self.labelspacing*fontsize,<EOL>align="<STR_LIT>",<EOL>children=itemBoxes))<EOL><DEDENT>if self._mode == "<STR_LIT>":<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>sep = self.columnspacing*fontsize<EOL>self._legend_box = HPacker(pad=self.borderpad*fontsize,<EOL>sep=sep, align="<STR_LIT>",<EOL>mode=mode,<EOL>children=columnbox)<EOL>self._legend_box.set_figure(self.figure)<EOL>self.texts = text_list<EOL>self.legendHandles = handle_list<EOL>

Initiallize the legend_box. The legend_box is an instance of
the OffsetBox, which is packed with legend handles and
texts. Once packed, their location is calculated during the
drawing time.


<EOL>fontsize = renderer.points_to_pixels(self.fontsize)<EOL>if self._last_fontsize_points == fontsize:<EOL><INDENT>return<EOL><DEDENT>height = self._approx_text_height(renderer) * <NUM_LIT><EOL>descent = <NUM_LIT:0.><EOL>for handle in self.legendHandles:<EOL><INDENT>if isinstance(handle, RegularPolyCollection):<EOL><INDENT>npoints = self.scatterpoints<EOL><DEDENT>else:<EOL><INDENT>npoints = self.numpoints<EOL><DEDENT>if npoints > <NUM_LIT:1>:<EOL><INDENT>xdata = np.linspace(<NUM_LIT>*fontsize,<EOL>(self.handlelength-<NUM_LIT>)*fontsize,<EOL>npoints)<EOL>xdata_marker = xdata<EOL><DEDENT>elif npoints == <NUM_LIT:1>:<EOL><INDENT>xdata = np.linspace(<NUM_LIT:0>, self.handlelength*fontsize, <NUM_LIT:2>)<EOL>xdata_marker = [<NUM_LIT:0.5>*self.handlelength*fontsize]<EOL><DEDENT>if isinstance(handle, Line2D):<EOL><INDENT>legline = handle<EOL>ydata = ((height-descent)/<NUM_LIT>)*np.ones(xdata.shape, float)<EOL>legline.set_data(xdata, ydata)<EOL>legline_marker = legline._legmarker<EOL>legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)])<EOL><DEDENT>elif isinstance(handle, Patch):<EOL><INDENT>p = handle<EOL>p.set_bounds(<NUM_LIT:0.>, <NUM_LIT:0.>,<EOL>self.handlelength*fontsize,<EOL>(height-descent),<EOL>)<EOL><DEDENT>elif isinstance(handle, RegularPolyCollection):<EOL><INDENT>p = handle<EOL>ydata = height*self._scatteryoffsets<EOL>p.set_offsets(zip(xdata_marker,ydata))<EOL><DEDENT><DEDENT>cor = fontsize / self._last_fontsize_points<EOL>def all_children(parent):<EOL><INDENT>yield parent<EOL>for c in parent.get_children():<EOL><INDENT>for cc in all_children(c): yield cc<EOL><DEDENT><DEDENT>for box in all_children(self._legend_box):<EOL><INDENT>if isinstance(box, PackerBase):<EOL><INDENT>box.pad = box.pad * cor<EOL>box.sep = box.sep * cor<EOL><DEDENT>elif isinstance(box, DrawingArea):<EOL><INDENT>box.width = self.handlelength*fontsize<EOL>box.height = height<EOL>box.xdescent = <NUM_LIT:0.><EOL>box.ydescent=descent<EOL><DEDENT><DEDENT>self._last_fontsize_points = fontsize<EOL>

Update the dimension of the legend_box. This is required
becuase the paddings, the hadle size etc. depends on the dpi
of the renderer.


assert self.isaxes <EOL>ax = self.parent<EOL>vertices = []<EOL>bboxes = []<EOL>lines = []<EOL>for handle in ax.lines:<EOL><INDENT>assert isinstance(handle, Line2D)<EOL>path = handle.get_path()<EOL>trans = handle.get_transform()<EOL>tpath = trans.transform_path(path)<EOL>lines.append(tpath)<EOL><DEDENT>for handle in ax.patches:<EOL><INDENT>assert isinstance(handle, Patch)<EOL>if isinstance(handle, Rectangle):<EOL><INDENT>transform = handle.get_data_transform()<EOL>bboxes.append(handle.get_bbox().transformed(transform))<EOL><DEDENT>else:<EOL><INDENT>transform = handle.get_transform()<EOL>bboxes.append(handle.get_path().get_extents(transform))<EOL><DEDENT><DEDENT>return [vertices, bboxes, lines]<EOL>

Returns list of vertices and extents covered by the plot.

Returns a two long list.

First element is a list of (x, y) vertices (in
display-coordinates) covered by all the lines and line
collections, in the legend's handles.

Second element is a list of bounding boxes for all the patches in
the legend's handles.


self._drawFrame = b<EOL>


children = []<EOL>if self._legend_box:<EOL><INDENT>children.append(self._legend_box)<EOL><DEDENT>return children<EOL>


return self.legendPatch<EOL>

return the Rectangle instance used to frame the legend


return [h for h in self.legendHandles if isinstance(h, Line2D)]<EOL>

return a list of lines.Line2D instances in the legend


return silent_list('<STR_LIT>', [h for h in self.legendHandles if isinstance(h, Patch)])<EOL>

return a list of patch instances in the legend


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

return a list of text.Text instance in the legend


return self.legendPatch.get_window_extent()<EOL>


def _get_anchored_bbox(self, loc, bbox, parentbbox, renderer):

assert loc in range(<NUM_LIT:1>,<NUM_LIT:11>) <EOL>BEST, UR, UL, LL, LR, R, CL, CR, LC, UC, C = range(<NUM_LIT:11>)<EOL>anchor_coefs={UR:"<STR_LIT>",<EOL>UL:"<STR_LIT>",<EOL>LL:"<STR_LIT>",<EOL>LR:"<STR_LIT>",<EOL>R:"<STR_LIT:E>",<EOL>CL:"<STR_LIT>",<EOL>CR:"<STR_LIT:E>",<EOL>LC:"<STR_LIT:S>",<EOL>UC:"<STR_LIT:N>",<EOL>C:"<STR_LIT:C>"}<EOL>c = anchor_coefs[loc]<EOL>fontsize = renderer.points_to_pixels(self.fontsize)<EOL>container = parentbbox.padded(-(self.borderaxespad) * fontsize)<EOL>anchored_box = bbox.anchored(c, container=container)<EOL>return anchored_box.x0, anchored_box.y0<EOL>

Place the *bbox* inside the *parentbbox* according to a given
location code. Return the (x,y) coordinate of the bbox.

- loc: a location code in range(1, 11).
  This corresponds to the possible values for self._loc, excluding "best".

- bbox: bbox to be placed, display coodinate units.
- parentbbox: a parent box which will contain the bbox. In
    display coordinates.


def _find_best_position(self, width, height, renderer, consider=None):

assert self.isaxes <EOL>verts, bboxes, lines = self._auto_legend_data()<EOL>bbox = Bbox.from_bounds(<NUM_LIT:0>, <NUM_LIT:0>, width, height)<EOL>consider = [self._get_anchored_bbox(x, bbox, self.parent.bbox, renderer) for x in range(<NUM_LIT:1>, len(self.codes))]<EOL>candidates = []<EOL>for l, b in consider:<EOL><INDENT>legendBox = Bbox.from_bounds(l, b, width, height)<EOL>badness = <NUM_LIT:0><EOL>badness = legendBox.count_contains(verts)<EOL>badness += legendBox.count_overlaps(bboxes)<EOL>for line in lines:<EOL><INDENT>if line.intersects_bbox(legendBox):<EOL><INDENT>badness += <NUM_LIT:1><EOL><DEDENT><DEDENT>ox, oy = l, b<EOL>if badness == <NUM_LIT:0>:<EOL><INDENT>return ox, oy<EOL><DEDENT>candidates.append((badness, (l, b)))<EOL><DEDENT>minCandidate = candidates[<NUM_LIT:0>]<EOL>for candidate in candidates:<EOL><INDENT>if candidate[<NUM_LIT:0>] < minCandidate[<NUM_LIT:0>]:<EOL><INDENT>minCandidate = candidate<EOL><DEDENT><DEDENT>ox, oy = minCandidate[<NUM_LIT:1>]<EOL>return ox, oy<EOL>

Determine the best location to place the legend.

`consider` is a list of (x, y) pairs to consider as a potential
lower-left corner of the legend. All are display coords.


def pilread():<EOL><INDENT>'<STR_LIT>'<EOL>try: import Image<EOL>except ImportError: return None<EOL>image = Image.open( fname )<EOL>return pil_to_array(image)<EOL><DEDENT>handlers = {'<STR_LIT>' :_png.read_png,<EOL>}<EOL>basename, ext = os.path.splitext(fname)<EOL>ext = ext.lower()[<NUM_LIT:1>:]<EOL>if ext not in list(handlers.keys()):<EOL><INDENT>im = pilread()<EOL>if im is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % list(handlers.keys()))<EOL><DEDENT>return im<EOL><DEDENT>handler = handlers[ext]<EOL>return handler(fname)<EOL>

Return image file in *fname* as :class:`numpy.array`.

Return value is a :class:`numpy.array`.  For grayscale images, the
return array is MxN.  For RGB images, the return value is MxNx3.
For RGBA images the return value is MxNx4.

matplotlib can only read PNGs natively, but if `PIL
<http://www.pythonware.com/products/pil/>`_ is installed, it will
use it to load the image and return an array (if possible) which
can be used with :func:`~matplotlib.pyplot.imshow`.

TODO: support RGB and grayscale return values in _image.readpng


def toarray(im):<EOL><INDENT>'<STR_LIT>'<EOL>x_str = im.tostring('<STR_LIT>',im.mode,<NUM_LIT:0>,-<NUM_LIT:1>)<EOL>x = np.fromstring(x_str,np.uint8)<EOL>return x<EOL><DEDENT>if pilImage.mode in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>im = pilImage <EOL><DEDENT>elif pilImage.mode=='<STR_LIT:L>':<EOL><INDENT>im = pilImage <EOL>x = toarray(im)<EOL>x.shape = im.size[<NUM_LIT:1>], im.size[<NUM_LIT:0>]<EOL>return x<EOL><DEDENT>elif pilImage.mode=='<STR_LIT>':<EOL><INDENT>im = pilImage <EOL>x = toarray(im)<EOL>x.shape = im.size[<NUM_LIT:1>], im.size[<NUM_LIT:0>], <NUM_LIT:3><EOL>return x<EOL><DEDENT>else: <EOL><INDENT>try:<EOL><INDENT>im = pilImage.convert('<STR_LIT>')<EOL><DEDENT>except ValueError:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT><DEDENT>x = toarray(im)<EOL>x.shape = im.size[<NUM_LIT:1>], im.size[<NUM_LIT:0>], <NUM_LIT:4><EOL>return x<EOL>

load a PIL image and return it as a numpy array of uint8.  For
grayscale images, the return array is MxN.  For RGB images, the
return value is MxNx3.  For RGBA images the return value is MxNx4


def thumbnail(infile, thumbfile, scale=<NUM_LIT:0.1>, interpolation='<STR_LIT>',<EOL>preview=False):

basedir, basename = os.path.split(infile)<EOL>baseout, extout = os.path.splitext(thumbfile)<EOL>im = imread(infile)<EOL>rows, cols, depth = im.shape<EOL>dpi = <NUM_LIT:100><EOL>height = float(rows)/dpi*scale<EOL>width = float(cols)/dpi*scale<EOL>extension = extout.lower()<EOL>if preview:<EOL><INDENT>import matplotlib.pyplot as plt<EOL>fig = plt.figure(figsize=(width, height), dpi=dpi)<EOL><DEDENT>else:<EOL><INDENT>if extension=='<STR_LIT>':<EOL><INDENT>from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas<EOL><DEDENT>elif extension=='<STR_LIT>':<EOL><INDENT>from matplotlib.backends.backend_pdf import FigureCanvasPDF as FigureCanvas<EOL><DEDENT>elif extension=='<STR_LIT>':<EOL><INDENT>from matplotlib.backends.backend_svg import FigureCanvasSVG as FigureCanvas<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>from matplotlib.figure import Figure<EOL>fig = Figure(figsize=(width, height), dpi=dpi)<EOL>canvas = FigureCanvas(fig)<EOL><DEDENT>ax = fig.add_axes([<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:1>], aspect='<STR_LIT>', frameon=False, xticks=[], yticks=[])<EOL>basename, ext = os.path.splitext(basename)<EOL>ax.imshow(im, aspect='<STR_LIT>', resample=True, interpolation='<STR_LIT>')<EOL>fig.savefig(thumbfile, dpi=dpi)<EOL>return fig<EOL>

make a thumbnail of image in *infile* with output filename
*thumbfile*.

  *infile* the image file -- must be PNG or PIL readable if you
     have `PIL <http://www.pythonware.com/products/pil/>`_ installed

  *thumbfile*
    the thumbnail filename

  *scale*
    the scale factor for the thumbnail

  *interpolation*
    the interpolation scheme used in the resampling

  *preview*
    if True, the default backend (presumably a user interface
    backend) will be used which will cause a figure to be raised
    if :func:`~matplotlib.pyplot.show` is called.  If it is False,
    a pure image backend will be used depending on the extension,
    'png'->FigureCanvasAgg, 'pdf'->FigureCanvasPDF,
    'svg'->FigureCanvasSVG

See examples/misc/image_thumbnail.py.

.. htmlonly::

    :ref:`misc-image_thumbnail`

Return value is the figure instance containing the thumbnail


def __init__(self, ax,<EOL>cmap = None,<EOL>norm = None,<EOL>interpolation=None,<EOL>origin=None,<EOL>extent=None,<EOL>filternorm=<NUM_LIT:1>,<EOL>filterrad=<NUM_LIT>,<EOL>resample = False,<EOL>**kwargs<EOL>):

martist.Artist.__init__(self)<EOL>cm.ScalarMappable.__init__(self, norm, cmap)<EOL>if origin is None: origin = rcParams['<STR_LIT>']<EOL>self.origin = origin<EOL>self._extent = extent<EOL>self.set_filternorm(filternorm)<EOL>self.set_filterrad(filterrad)<EOL>self._filterrad = filterrad<EOL>self.set_interpolation(interpolation)<EOL>self.set_resample(resample)<EOL>self.axes = ax<EOL>self._imcache = None<EOL>self.update(kwargs)<EOL>

interpolation and cmap default to their rc settings

cmap is a colors.Colormap instance
norm is a colors.Normalize instance to map luminance to 0-1

extent is data axes (left, right, bottom, top) for making image plots
registered with data plots.  Default is to label the pixel
centers with the zero-based row and column indices.

Additional kwargs are matplotlib.artist properties


if self._A is None:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>return self._A.shape[:<NUM_LIT:2>]<EOL>

Get the numrows, numcols of the input image


martist.Artist.set_alpha(self, alpha)<EOL>self._imcache = None<EOL>

Set the alpha value used for blending - not supported on
all backends

ACCEPTS: float


self._imcache = None<EOL>self._rgbacache = None<EOL>cm.ScalarMappable.changed(self)<EOL>

Call this whenever the mappable is changed so observers can
update state


if callable(self._contains): return self._contains(self,mouseevent)<EOL>x, y = mouseevent.xdata, mouseevent.ydata<EOL>xmin, xmax, ymin, ymax = self.get_extent()<EOL>if xmin > xmax:<EOL><INDENT>xmin,xmax = xmax,xmin<EOL><DEDENT>if ymin > ymax:<EOL><INDENT>ymin,ymax = ymax,ymin<EOL><DEDENT>if x is not None and y is not None:<EOL><INDENT>inside = x>=xmin and x<=xmax and y>=ymin and y<=ymax<EOL><DEDENT>else:<EOL><INDENT>inside = False<EOL><DEDENT>return inside,{}<EOL>

Test whether the mouse event occured within the image.


def write_png(self, fname, noscale=False):

im = self.make_image()<EOL>if noscale:<EOL><INDENT>numrows, numcols = im.get_size()<EOL>im.reset_matrix()<EOL>im.set_interpolation(<NUM_LIT:0>)<EOL>im.resize(numcols, numrows)<EOL><DEDENT>im.flipud_out()<EOL>rows, cols, buffer = im.as_rgba_str()<EOL>_png.write_png(buffer, cols, rows, fname)<EOL>


<EOL>if hasattr(A,'<STR_LIT>'):<EOL><INDENT>self._A = pil_to_array(A)<EOL><DEDENT>elif ma.isMA(A):<EOL><INDENT>self._A = A<EOL><DEDENT>else:<EOL><INDENT>self._A = np.asarray(A) <EOL><DEDENT>if self._A.dtype != np.uint8 and not np.can_cast(self._A.dtype, np.float):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if (self._A.ndim not in (<NUM_LIT:2>, <NUM_LIT:3>) or<EOL>(self._A.ndim == <NUM_LIT:3> and self._A.shape[-<NUM_LIT:1>] not in (<NUM_LIT:3>, <NUM_LIT:4>))):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>self._imcache =None<EOL>self._rgbacache = None<EOL>self._oldxslice = None<EOL>self._oldyslice = None<EOL>

Set the image array

ACCEPTS: numpy/PIL Image A


retained for backwards compatibility - use set_data instead

ACCEPTS: numpy array A or PIL Image


self._extent = extent<EOL>xmin, xmax, ymin, ymax = extent<EOL>corners = (xmin, ymin), (xmax, ymax)<EOL>self.axes.update_datalim(corners)<EOL>if self.axes._autoscaleon:<EOL><INDENT>self.axes.set_xlim((xmin, xmax))<EOL>self.axes.set_ylim((ymin, ymax))<EOL><DEDENT>

extent is data axes (left, right, bottom, top) for making image plots


return self._interpolation<EOL>

Return the interpolation method the image uses when resizing.

One of 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning',
'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian',
'bessel', 'mitchell', 'sinc', 'lanczos',


if s is None: s = rcParams['<STR_LIT>']<EOL>s = s.lower()<EOL>if s not in self._interpd:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>self._interpolation = s<EOL>

Set the interpolation method the image uses when resizing.

ACCEPTS: ['nearest' | 'bilinear' | 'bicubic' | 'spline16' |
  'spline36' | 'hanning' | 'hamming' | 'hermite' | 'kaiser' |
  'quadric' | 'catrom' | 'gaussian' | 'bessel' | 'mitchell' |
  'sinc' | 'lanczos' | ]


if self._extent is not None:<EOL><INDENT>return self._extent<EOL><DEDENT>else:<EOL><INDENT>sz = self.get_size()<EOL>numrows, numcols = sz<EOL>if self.origin == '<STR_LIT>':<EOL><INDENT>return (-<NUM_LIT:0.5>, numcols-<NUM_LIT:0.5>, numrows-<NUM_LIT:0.5>, -<NUM_LIT:0.5>)<EOL><DEDENT>else:<EOL><INDENT>return (-<NUM_LIT:0.5>, numcols-<NUM_LIT:0.5>, -<NUM_LIT:0.5>, numrows-<NUM_LIT:0.5>)<EOL><DEDENT><DEDENT>

get the image extent: left, right, bottom, top


if filternorm:<EOL><INDENT>self._filternorm = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>self._filternorm = <NUM_LIT:0><EOL><DEDENT>

Set whether the resize filter norms the weights -- see
        help for imshow

        ACCEPTS: 0 or 1


return self._filternorm<EOL>


r = float(filterrad)<EOL>assert(r><NUM_LIT:0>)<EOL>self._filterrad = r<EOL>

Set the resize filter radius only applicable to some
        interpolation schemes -- see help for imshow

        ACCEPTS: positive float


return self._filterrad<EOL>


def __init__(self, ax,<EOL>x=None,<EOL>y=None,<EOL>A=None,<EOL>cmap = None,<EOL>norm = None,<EOL>**kwargs<EOL>):

martist.Artist.__init__(self)<EOL>cm.ScalarMappable.__init__(self, norm, cmap)<EOL>self.axes = ax<EOL>self._rgbacache = None<EOL>self.update(kwargs)<EOL>self.set_data(x, y, A)<EOL>

cmap defaults to its rc setting

cmap is a colors.Colormap instance
norm is a colors.Normalize instance to map luminance to 0-1

Additional kwargs are matplotlib.artist properties


martist.Artist.set_alpha(self, alpha)<EOL>self.update_dict['<STR_LIT>'] = True<EOL>


def __init__(self, fig,<EOL>cmap = None,<EOL>norm = None,<EOL>offsetx = <NUM_LIT:0>,<EOL>offsety = <NUM_LIT:0>,<EOL>origin=None,<EOL>**kwargs<EOL>):

martist.Artist.__init__(self)<EOL>cm.ScalarMappable.__init__(self, norm, cmap)<EOL>if origin is None: origin = rcParams['<STR_LIT>']<EOL>self.origin = origin<EOL>self.figure = fig<EOL>self.ox = offsetx<EOL>self.oy = offsety<EOL>self.update(kwargs)<EOL>self.magnification = <NUM_LIT:1.0><EOL>

cmap is a colors.Colormap instance
norm is a colors.Normalize instance to map luminance to 0-1

kwargs are an optional list of Artist keyword args


if callable(self._contains): return self._contains(self,mouseevent)<EOL>xmin, xmax, ymin, ymax = self.get_extent()<EOL>xdata, ydata = mouseevent.x, mouseevent.y<EOL>if xdata is not None and ydata is not None:<EOL><INDENT>inside = xdata>=xmin and xdata<=xmax and ydata>=ymin and ydata<=ymax<EOL><DEDENT>else:<EOL><INDENT>inside = False<EOL><DEDENT>return inside,{}<EOL>


numrows, numcols = self.get_size()<EOL>return (-<NUM_LIT:0.5>+self.ox, numcols-<NUM_LIT:0.5>+self.ox,<EOL>-<NUM_LIT:0.5>+self.oy, numrows-<NUM_LIT:0.5>+self.oy)<EOL>


im = self.make_image()<EOL>rows, cols, buffer = im.as_rgba_str()<EOL>_png.write_png(buffer, cols, rows, fname)<EOL>


props = []<EOL>families = '<STR_LIT>'<EOL>size = '<STR_LIT>'<EOL>for key in '<STR_LIT>'.split():<EOL><INDENT>val = getattr(d, '<STR_LIT>' + key)()<EOL>if val is not None and val != []:<EOL><INDENT>if type(val) == list:<EOL><INDENT>val = [value_escape(r'<STR_LIT>', str(x)) for x in val if x is not None]<EOL>if val != []:<EOL><INDENT>val = '<STR_LIT:U+002C>'.join(val)<EOL><DEDENT><DEDENT>props.append("<STR_LIT>" % (key, val))<EOL><DEDENT><DEDENT>return '<STR_LIT>'.join(props)<EOL>

Given a dictionary of key/value pairs, generates a fontconfig
pattern string.


props = self._properties = {}<EOL>try:<EOL><INDENT>self._parser.parseString(pattern)<EOL><DEDENT>except self.ParseException as e:<EOL><INDENT>raise ValueError("<STR_LIT>" % (pattern, e))<EOL><DEDENT>self._properties = None<EOL>return props<EOL>

Parse the given fontconfig *pattern* and return a dictionary
of key/value pairs useful for initializing a
:class:`font_manager.FontProperties` object.


<EOL>self.add_event(event)<EOL>verbose.report("<STR_LIT>" % len(self.events))<EOL>self.post_event()<EOL>if len(self.events) >= self.n and self.n > <NUM_LIT:0>:<EOL><INDENT>self.fig.canvas.stop_event_loop()<EOL><DEDENT>

Event handler that will be passed to the current figure to
retrieve events.


pass<EOL>

For baseclass, do nothing but collect events


for cb in self.callbacks:<EOL><INDENT>self.fig.canvas.mpl_disconnect(cb)<EOL><DEDENT>self.callbacks=[]<EOL>


self.events.append(event)<EOL>

For base class, this just appends an event to events.


self.events.pop(index)<EOL>

This removes an event from the event list.  Defaults to
removing last event, but an index can be supplied.  Note that
this does not check that there are events, much like the
normal pop method.  If not events exist, this will throw an
exception.


def __call__(self, n=<NUM_LIT:1>, timeout=<NUM_LIT:30> ):

assert isinstance(n, int), "<STR_LIT>"<EOL>self.n = n<EOL>self.events = []<EOL>self.callbacks = []<EOL>self.fig.show()<EOL>for n in self.eventslist:<EOL><INDENT>self.callbacks.append( self.fig.canvas.mpl_connect(n, self.on_event) )<EOL><DEDENT>try:<EOL><INDENT>self.fig.canvas.start_event_loop(timeout=timeout)<EOL><DEDENT>finally: <EOL><INDENT>self.cleanup()<EOL><DEDENT>return self.events<EOL>


assert len(self.events)><NUM_LIT:0>, "<STR_LIT>"<EOL>if self.events[-<NUM_LIT:1>].name == '<STR_LIT>':<EOL><INDENT>self.key_event()<EOL><DEDENT>else:<EOL><INDENT>self.mouse_event()<EOL><DEDENT>


event = self.events[-<NUM_LIT:1>]<EOL>button = event.button<EOL>if button == <NUM_LIT:3>:<EOL><INDENT>self.button3(event)<EOL><DEDENT>elif button == <NUM_LIT:2>:<EOL><INDENT>self.button2(event)<EOL><DEDENT>else:<EOL><INDENT>self.button1(event)<EOL><DEDENT>


event = self.events[-<NUM_LIT:1>]<EOL>key = event.key<EOL>if key == '<STR_LIT>' or key == '<STR_LIT>':<EOL><INDENT>self.button3(event)<EOL><DEDENT>elif key == '<STR_LIT>':<EOL><INDENT>self.button2(event)<EOL><DEDENT>else:<EOL><INDENT>self.button1(event)<EOL><DEDENT>

Process a key click event.  This maps certain keys to appropriate
mouse click events.


if event.inaxes:<EOL><INDENT>self.add_click(event)<EOL><DEDENT>else: <EOL><INDENT>BlockingInput.pop(self)<EOL><DEDENT>

Will be called for any event involving a button other than
button 2 or 3.  This will add a click if it is inside axes.


<EOL>BlockingInput.pop(self)<EOL>self.fig.canvas.stop_event_loop()<EOL>

Will be called for any event involving button 2.
Button 2 ends blocking input.


<EOL>BlockingInput.pop(self)<EOL>if len(self.events)><NUM_LIT:0>:<EOL><INDENT>self.pop()<EOL><DEDENT>

Will be called for any event involving button 3.
Button 3 removes the last click.


self.clicks.append((event.xdata,event.ydata))<EOL>verbose.report("<STR_LIT>" %<EOL>(len(self.clicks),event.xdata, event.ydata))<EOL>if self.show_clicks:<EOL><INDENT>self.marks.extend(<EOL>event.inaxes.plot([event.xdata,], [event.ydata,], '<STR_LIT>') )<EOL>self.fig.canvas.draw()<EOL><DEDENT>

This add the coordinates of an event to the list of clicks


self.clicks.pop(index)<EOL>if self.show_clicks:<EOL><INDENT>mark = self.marks.pop(index)<EOL>mark.remove()<EOL>self.fig.canvas.draw()<EOL><DEDENT>

This removes a click from the list of clicks.  Defaults to
removing the last click.


self.pop_click(index)<EOL>BlockingInput.pop(self,index)<EOL>

This removes a click and the associated event from the object.
Defaults to removing the last click, but any index can be
supplied.


def __call__(self, n=<NUM_LIT:1>, timeout=<NUM_LIT:30>, show_clicks=True):

self.show_clicks = show_clicks<EOL>self.clicks      = []<EOL>self.marks       = []<EOL>BlockingInput.__call__(self,n=n,timeout=timeout)<EOL>return self.clicks<EOL>

Blocking call to retrieve n coordinate pairs through mouse
clicks.


<EOL>cs = self.cs<EOL>if event.inaxes == cs.ax:<EOL><INDENT>conmin,segmin,imin,xmin,ymin = cs.find_nearest_contour(<EOL>event.x, event.y, cs.labelIndiceList)[:<NUM_LIT:5>]<EOL>lmin = cs.labelIndiceList.index(conmin)<EOL>paths = cs.collections[conmin].get_paths()<EOL>lc = paths[segmin].vertices<EOL>slc = cs.ax.transData.transform(lc)<EOL>lw = cs.get_label_width(cs.labelLevelList[lmin],<EOL>cs.labelFmt, cs.labelFontSizeList[lmin])<EOL>"""<STR_LIT>"""<EOL>if self.inline: lcarg = lc<EOL>else: lcarg = None<EOL>rotation,nlc = cs.calc_label_rot_and_inline(<EOL>slc, imin, lw, lcarg,<EOL>self.inline_spacing )<EOL>cs.add_label(xmin,ymin,rotation,cs.labelLevelList[lmin],<EOL>cs.labelCValueList[lmin])<EOL>if self.inline:<EOL><INDENT>paths.pop(segmin)<EOL>for n in nlc:<EOL><INDENT>if len(n)><NUM_LIT:1>:<EOL><INDENT>paths.append( path.Path(n) )<EOL><DEDENT><DEDENT><DEDENT>self.fig.canvas.draw()<EOL><DEDENT>else: <EOL><INDENT>BlockingInput.pop(self)<EOL><DEDENT>

This will be called if an event involving a button other than
2 or 3 occcurs.  This will add a label to a contour.


<EOL>BlockingInput.pop(self)<EOL>if self.inline:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>self.cs.pop_label()<EOL>self.cs.ax.figure.canvas.draw()<EOL><DEDENT>

This will be called if button 3 is clicked.  This will remove
a label if not in inline mode.  Unfortunately, if one is doing
inline labels, then there is currently no way to fix the
broken contour - once humpty-dumpty is broken, he can't be put
back together.  In inline mode, this does nothing.


assert len(self.events)><NUM_LIT:0>, "<STR_LIT>"<EOL>self.keyormouse = self.events[-<NUM_LIT:1>].name == '<STR_LIT>'<EOL>


self.keyormouse = None<EOL>BlockingInput.__call__(self,n=<NUM_LIT:1>,timeout=timeout)<EOL>return self.keyormouse<EOL>

Blocking call to retrieve a single mouse or key click
Returns True if key click, False if mouse, or None if timeout


artist.Artist.__init__(self)<EOL>cm.ScalarMappable.__init__(self, norm, cmap)<EOL>self.set_edgecolor(edgecolors)<EOL>self.set_facecolor(facecolors)<EOL>self.set_linewidth(linewidths)<EOL>self.set_linestyle(linestyles)<EOL>self.set_antialiased(antialiaseds)<EOL>self.set_urls(urls)<EOL>self._uniform_offsets = None<EOL>self._offsets = np.array([], np.float_)<EOL>if offsets is not None:<EOL><INDENT>offsets = np.asarray(offsets)<EOL>if len(offsets.shape) == <NUM_LIT:1>:<EOL><INDENT>offsets = offsets[np.newaxis, :]  <EOL><DEDENT>if transOffset is not None:<EOL><INDENT>self._offsets = offsets<EOL>self._transOffset = transOffset<EOL><DEDENT>else:<EOL><INDENT>self._uniform_offsets = offsets<EOL><DEDENT><DEDENT>self._pickradius = pickradius<EOL>self.update(kwargs)<EOL>


transform = self.get_transform()<EOL>transOffset = self._transOffset<EOL>offsets = self._offsets<EOL>paths = self.get_paths()<EOL>if self.have_units():<EOL><INDENT>paths = []<EOL>for path in self.get_paths():<EOL><INDENT>vertices = path.vertices<EOL>xs, ys = vertices[:, <NUM_LIT:0>], vertices[:, <NUM_LIT:1>]<EOL>xs = self.convert_xunits(xs)<EOL>ys = self.convert_yunits(ys)<EOL>paths.append(mpath.Path(zip(xs, ys), path.codes))<EOL><DEDENT>if len(self._offsets):<EOL><INDENT>xs = self.convert_xunits(self._offsets[:<NUM_LIT:0>])<EOL>ys = self.convert_yunits(self._offsets[:<NUM_LIT:1>])<EOL>offsets = zip(xs, ys)<EOL><DEDENT><DEDENT>offsets = np.asarray(offsets, np.float_)<EOL>if not transform.is_affine:<EOL><INDENT>paths = [transform.transform_path_non_affine(<EOL>path) for path in paths]<EOL>transform = transform.get_affine()<EOL><DEDENT>if not transOffset.is_affine:<EOL><INDENT>offsets = transOffset.transform_non_affine(offsets)<EOL>transOffset = transOffset.get_affine()<EOL><DEDENT>return transform, transOffset, offsets, paths<EOL>


if callable(self._contains):<EOL><INDENT>return self._contains(self, mouseevent)<EOL><DEDENT>if not self.get_visible():<EOL><INDENT>return False, {}<EOL><DEDENT>transform, transOffset, offsets, paths = self._prepare_points()<EOL>ind = mpath.point_in_path_collection(<EOL>mouseevent.x, mouseevent.y, self._pickradius,<EOL>transform.frozen(), paths, self.get_transforms(),<EOL>offsets, transOffset, len(self._facecolors) > <NUM_LIT:0>)<EOL>return len(ind) > <NUM_LIT:0>, dict(ind=ind)<EOL>

Test whether the mouse event occurred in the collection.

Returns True | False, ``dict(ind=itemlist)``, where every
item in itemlist contains the event.


offsets = np.asarray(offsets, np.float_)<EOL>if len(offsets.shape) == <NUM_LIT:1>:<EOL><INDENT>offsets = offsets[np.newaxis, :]  <EOL><DEDENT>if self._uniform_offsets is None:<EOL><INDENT>self._offsets = offsets<EOL><DEDENT>else:<EOL><INDENT>self._uniform_offsets = offsets<EOL><DEDENT>

Set the offsets for the collection.  *offsets* can be a scalar
or a sequence.

ACCEPTS: float or sequence of floats


<EOL>if self._uniform_offsets is None:<EOL><INDENT>return self._offsets<EOL><DEDENT>else:<EOL><INDENT>return self._uniform_offsets<EOL><DEDENT>


if lw is None:<EOL><INDENT>lw = mpl.rcParams['<STR_LIT>']<EOL><DEDENT>self._linewidths = self._get_value(lw)<EOL>

Set the linewidth(s) for the collection.  *lw* can be a scalar
or a sequence; if it is a sequence the patches will cycle
through the sequence

ACCEPTS: float or sequence of floats


return self.set_linewidth(lw)<EOL>