def grid(self, b=None, which='<STR_LIT>', **kwargs):

if len(kwargs): b = True<EOL>if which.lower().find('<STR_LIT>')>=<NUM_LIT:0>:<EOL><INDENT>if b is None: self._gridOnMinor = not self._gridOnMinor<EOL>else: self._gridOnMinor = b<EOL>for tick in self.minorTicks:  <EOL><INDENT>if tick is None: continue<EOL>tick.gridOn = self._gridOnMinor<EOL>if len(kwargs): artist.setp(tick.gridline,**kwargs)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if b is None: self._gridOnMajor = not self._gridOnMajor<EOL>else: self._gridOnMajor = b<EOL>for tick in self.majorTicks:  <EOL><INDENT>if tick is None: continue<EOL>tick.gridOn = self._gridOnMajor<EOL>if len(kwargs): artist.setp(tick.gridline,**kwargs)<EOL><DEDENT><DEDENT>

Set the axis grid on or off; b is a boolean use *which* =
'major' | 'minor' to set the grid for major or minor ticks

if *b* is *None* and len(kwargs)==0, toggle the grid state.  If
*kwargs* are supplied, it is assumed you want the grid on and *b*
will be set to True

*kwargs* are used to set the line properties of the grids, eg,

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


converter = munits.registry.get_converter(data)<EOL>if converter is None: return False<EOL>self.converter = converter<EOL>default = self.converter.default_units(data)<EOL>if default is not None and self.units is None:<EOL><INDENT>self.set_units(default)<EOL><DEDENT>self._update_axisinfo()<EOL>return True<EOL>

introspect *data* for units converter and update the
axis.converter instance if necessary. Return *True* is *data* is
registered for unit conversion


if self.converter is None:<EOL><INDENT>return<EOL><DEDENT>info = self.converter.axisinfo(self.units)<EOL>if info is None:<EOL><INDENT>return<EOL><DEDENT>if info.majloc is not None and self.major.locator!=info.majloc:<EOL><INDENT>self.set_major_locator(info.majloc)<EOL><DEDENT>if info.minloc is not None and self.minor.locator!=info.minloc:<EOL><INDENT>self.set_minor_locator(info.minloc)<EOL><DEDENT>if info.majfmt is not None and self.major.formatter!=info.majfmt:<EOL><INDENT>self.set_major_formatter(info.majfmt)<EOL><DEDENT>if info.minfmt is not None and self.minor.formatter!=info.minfmt:<EOL><INDENT>self.set_minor_formatter(info.minfmt)<EOL><DEDENT>if info.label is not None:<EOL><INDENT>label = self.get_label()<EOL>label.set_text(info.label)<EOL><DEDENT>

check the axis converter for the stored units to see if the
axis info needs to be updated


pchanged = False<EOL>if u is None:<EOL><INDENT>self.units = None<EOL>pchanged = True<EOL><DEDENT>else:<EOL><INDENT>if u!=self.units:<EOL><INDENT>self.units = u<EOL>pchanged = True<EOL><DEDENT><DEDENT>if pchanged:<EOL><INDENT>self._update_axisinfo()<EOL>self.callbacks.process('<STR_LIT>')<EOL>self.callbacks.process('<STR_LIT>')<EOL><DEDENT>

set the units for axis

ACCEPTS: a units tag


return self.units<EOL>


self.major.formatter = formatter<EOL>formatter.set_axis(self)<EOL>

Set the formatter of the major ticker

ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance


self.minor.formatter = formatter<EOL>formatter.set_axis(self)<EOL>

Set the formatter of the minor ticker

ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance


self.major.locator = locator<EOL>locator.set_axis(self)<EOL>

Set the locator of the major ticker

ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance


self.minor.locator = locator<EOL>locator.set_axis(self)<EOL>

Set the locator of the minor ticker

ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance


self.pickradius = pickradius<EOL>

Set the depth of the axis used by the picker

ACCEPTS: a distance in points


def set_ticklabels(self, ticklabels, *args, **kwargs):

<EOL>minor = kwargs.pop('<STR_LIT>', False)<EOL>if minor:<EOL><INDENT>self.set_minor_formatter(mticker.FixedFormatter(ticklabels))<EOL>ticks = self.get_minor_ticks()<EOL><DEDENT>else:<EOL><INDENT>self.set_major_formatter( mticker.FixedFormatter(ticklabels) )<EOL>ticks = self.get_major_ticks()<EOL><DEDENT>self.set_major_formatter( mticker.FixedFormatter(ticklabels) )<EOL>ret = []<EOL>for i, tick in enumerate(ticks):<EOL><INDENT>if i<len(ticklabels):<EOL><INDENT>tick.label1.set_text(ticklabels[i])<EOL>ret.append(tick.label1)<EOL><DEDENT>tick.label1.update(kwargs)<EOL><DEDENT>return ret<EOL>

Set the text values of the tick labels. Return a list of Text
instances.  Use *kwarg* *minor=True* to select minor ticks.

ACCEPTS: sequence of strings


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

<EOL>ticks = self.convert_units(ticks)<EOL>if len(ticks) > <NUM_LIT:1>:<EOL><INDENT>xleft, xright = self.get_view_interval()<EOL>if xright > xleft:<EOL><INDENT>self.set_view_interval(min(ticks), max(ticks))<EOL><DEDENT>else:<EOL><INDENT>self.set_view_interval(max(ticks), min(ticks))<EOL><DEDENT><DEDENT>if minor:<EOL><INDENT>self.set_minor_locator(mticker.FixedLocator(ticks))<EOL>return self.get_minor_ticks(len(ticks))<EOL><DEDENT>else:<EOL><INDENT>self.set_major_locator( mticker.FixedLocator(ticks) )<EOL>return self.get_major_ticks(len(ticks))<EOL><DEDENT>

Set the locations of the tick marks from sequence ticks

ACCEPTS: sequence of floats


def _update_label_position(self, bboxes, bboxes2):

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

Update the label position based on the sequence of bounding
boxes of all the ticklabels


def _update_offset_text_postion(self, bboxes, bboxes2):


self.major.locator.pan(numsteps)<EOL>

Pan *numsteps* (can be positive or negative)


self.major.locator.zoom(direction)<EOL>

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


if callable(self._contains): return self._contains(self,mouseevent)<EOL>x,y = mouseevent.x,mouseevent.y<EOL>try:<EOL><INDENT>trans = self.axes.transAxes.inverted()<EOL>xaxes,yaxes = trans.transform_point((x,y))<EOL><DEDENT>except ValueError:<EOL><INDENT>return False, {}<EOL><DEDENT>l,b = self.axes.transAxes.transform_point((<NUM_LIT:0>,<NUM_LIT:0>))<EOL>r,t = self.axes.transAxes.transform_point((<NUM_LIT:1>,<NUM_LIT:1>))<EOL>inaxis = xaxes>=<NUM_LIT:0> and xaxes<=<NUM_LIT:1> and (<EOL>(y<b and y>b-self.pickradius) or<EOL>(y>t and y<t+self.pickradius))<EOL>return inaxis, {}<EOL>

Test whether the mouse event occured in the x axis.


return self.label_position<EOL>

Return the label position (top or bottom)


assert position == '<STR_LIT>' or position == '<STR_LIT>'<EOL>if position == '<STR_LIT>':<EOL><INDENT>self.label.set_verticalalignment('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>self.label.set_verticalalignment('<STR_LIT>')<EOL><DEDENT>self.label_position=position<EOL>

Set the label position (top or bottom)

ACCEPTS: [ 'top' | 'bottom' ]


if not self._autolabelpos: return<EOL>x,y = self.label.get_position()<EOL>if self.label_position == '<STR_LIT>':<EOL><INDENT>if not len(bboxes):<EOL><INDENT>bottom = self.axes.bbox.ymin<EOL><DEDENT>else:<EOL><INDENT>bbox = mtransforms.Bbox.union(bboxes)<EOL>bottom = bbox.y0<EOL><DEDENT>self.label.set_position( (x, bottom - self.LABELPAD*self.figure.dpi / <NUM_LIT>))<EOL><DEDENT>else:<EOL><INDENT>if not len(bboxes2):<EOL><INDENT>top = self.axes.bbox.ymax<EOL><DEDENT>else:<EOL><INDENT>bbox = mtransforms.Bbox.union(bboxes2)<EOL>top = bbox.y1<EOL><DEDENT>self.label.set_position( (x, top+self.LABELPAD*self.figure.dpi / <NUM_LIT>))<EOL><DEDENT>


def _update_offset_text_position(self, bboxes, bboxes2):

x,y = self.offsetText.get_position()<EOL>if not len(bboxes):<EOL><INDENT>bottom = self.axes.bbox.ymin<EOL><DEDENT>else:<EOL><INDENT>bbox = mtransforms.Bbox.union(bboxes)<EOL>bottom = bbox.y0<EOL><DEDENT>self.offsetText.set_position((x, bottom-self.OFFSETTEXTPAD*self.figure.dpi/<NUM_LIT>))<EOL>

Update the offset_text position based on the sequence of bounding
boxes of all the ticklabels


bbox, bbox2 = self.get_ticklabel_extents(renderer)<EOL>padPixels = self.majorTicks[<NUM_LIT:0>].get_pad_pixels()<EOL>above = <NUM_LIT:0.0><EOL>if bbox2.height:<EOL><INDENT>above += bbox2.height + padPixels<EOL><DEDENT>below = <NUM_LIT:0.0><EOL>if bbox.height:<EOL><INDENT>below += bbox.height + padPixels<EOL><DEDENT>if self.get_label_position() == '<STR_LIT>':<EOL><INDENT>above += self.label.get_window_extent(renderer).height + padPixels<EOL><DEDENT>else:<EOL><INDENT>below += self.label.get_window_extent(renderer).height + padPixels<EOL><DEDENT>return above, below<EOL>

Returns the amount of space one should reserve for text
above and below the axes.  Returns a tuple (above, below)


assert position in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:default>', '<STR_LIT:none>')<EOL>ticks = list( self.get_major_ticks() )  <EOL>ticks.extend( self.get_minor_ticks() )<EOL>if position == '<STR_LIT>':<EOL><INDENT>for t in ticks:<EOL><INDENT>t.tick1On = False<EOL>t.tick2On = True<EOL>t.label1On = False<EOL>t.label2On = True<EOL><DEDENT><DEDENT>elif position == '<STR_LIT>':<EOL><INDENT>for t in ticks:<EOL><INDENT>t.tick1On = True<EOL>t.tick2On = False<EOL>t.label1On = True<EOL>t.label2On = False<EOL><DEDENT><DEDENT>elif position == '<STR_LIT:default>':<EOL><INDENT>for t in ticks:<EOL><INDENT>t.tick1On = True<EOL>t.tick2On = True<EOL>t.label1On = True<EOL>t.label2On = False<EOL><DEDENT><DEDENT>elif position == '<STR_LIT:none>':<EOL><INDENT>for t in ticks:<EOL><INDENT>t.tick1On = False<EOL>t.tick2On = False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for t in ticks:<EOL><INDENT>t.tick1On = True<EOL>t.tick2On = True<EOL><DEDENT><DEDENT>for t in ticks:<EOL><INDENT>t.update_position(t._loc)<EOL><DEDENT>

Set the ticks position (top, bottom, both, default or none)
both sets the ticks to appear on both positions, but does not
change the tick labels.  default resets the tick positions to
the default: ticks on both positions, labels at bottom.  none
can be used if you don't want any ticks.

ACCEPTS: [ 'top' | 'bottom' | 'both' | 'default' | 'none' ]


self.set_ticks_position('<STR_LIT>')<EOL>


majt=self.majorTicks[<NUM_LIT:0>]<EOL>mT=self.minorTicks[<NUM_LIT:0>]<EOL>majorTop=(not majt.tick1On) and majt.tick2On and (not majt.label1On) and majt.label2On<EOL>minorTop=(not mT.tick1On) and mT.tick2On and (not mT.label1On) and mT.label2On<EOL>if majorTop and minorTop: return '<STR_LIT>'<EOL>MajorBottom=majt.tick1On and (not majt.tick2On) and majt.label1On and (not majt.label2On)<EOL>MinorBottom=mT.tick1On and (not mT.tick2On) and mT.label1On and (not mT.label2On)<EOL>if MajorBottom and MinorBottom: return '<STR_LIT>'<EOL>majorDefault=majt.tick1On and majt.tick2On and majt.label1On and (not majt.label2On)<EOL>minorDefault=mT.tick1On and mT.tick2On and mT.label1On and (not mT.label2On)<EOL>if majorDefault and minorDefault: return '<STR_LIT:default>'<EOL>return '<STR_LIT>'<EOL>

Return the ticks position (top, bottom, default or unknown)


return self.axes.viewLim.intervalx<EOL>

return the Interval instance for this axis view limits


return self.axes.dataLim.intervalx<EOL>

return the Interval instance for this axis data limits


def set_data_interval(self, vmin, vmax, ignore=False):

if ignore:<EOL><INDENT>self.axes.dataLim.intervalx = vmin, vmax<EOL><DEDENT>else:<EOL><INDENT>Vmin, Vmax = self.get_data_interval()<EOL>self.axes.dataLim.intervalx = min(vmin, Vmin), max(vmax, Vmax)<EOL><DEDENT>


if callable(self._contains): return self._contains(self,mouseevent)<EOL>x,y = mouseevent.x,mouseevent.y<EOL>try:<EOL><INDENT>trans = self.axes.transAxes.inverted()<EOL>xaxes,yaxes = trans.transform_point((x,y))<EOL><DEDENT>except ValueError:<EOL><INDENT>return False, {}<EOL><DEDENT>l,b = self.axes.transAxes.transform_point((<NUM_LIT:0>,<NUM_LIT:0>))<EOL>r,t = self.axes.transAxes.transform_point((<NUM_LIT:1>,<NUM_LIT:1>))<EOL>inaxis = yaxes>=<NUM_LIT:0> and yaxes<=<NUM_LIT:1> and (<EOL>(x<l and x>l-self.pickradius) or<EOL>(x>r and x<r+self.pickradius))<EOL>return inaxis, {}<EOL>

Test whether the mouse event occurred in the y axis.

        Returns *True* | *False*


return self.label_position<EOL>

Return the label position (left or right)


assert position == '<STR_LIT:left>' or position == '<STR_LIT:right>'<EOL>if position == '<STR_LIT:right>':<EOL><INDENT>self.label.set_horizontalalignment('<STR_LIT:left>')<EOL><DEDENT>else:<EOL><INDENT>self.label.set_horizontalalignment('<STR_LIT:right>')<EOL><DEDENT>self.label_position=position<EOL>

Set the label position (left or right)

ACCEPTS: [ 'left' | 'right' ]


if not self._autolabelpos: return<EOL>x,y = self.label.get_position()<EOL>if self.label_position == '<STR_LIT:left>':<EOL><INDENT>if not len(bboxes):<EOL><INDENT>left = self.axes.bbox.xmin<EOL><DEDENT>else:<EOL><INDENT>bbox = mtransforms.Bbox.union(bboxes)<EOL>left = bbox.x0<EOL><DEDENT>self.label.set_position( (left-self.LABELPAD*self.figure.dpi/<NUM_LIT>, y))<EOL><DEDENT>else:<EOL><INDENT>if not len(bboxes2):<EOL><INDENT>right = self.axes.bbox.xmax<EOL><DEDENT>else:<EOL><INDENT>bbox = mtransforms.Bbox.union(bboxes2)<EOL>right = bbox.x1<EOL><DEDENT>self.label.set_position( (right+self.LABELPAD*self.figure.dpi/<NUM_LIT>, y))<EOL><DEDENT>


x,y = self.offsetText.get_position()<EOL>top = self.axes.bbox.ymax<EOL>self.offsetText.set_position((x, top+self.OFFSETTEXTPAD*self.figure.dpi/<NUM_LIT>))<EOL>


assert position in ('<STR_LIT:left>', '<STR_LIT:right>', '<STR_LIT>', '<STR_LIT:default>', '<STR_LIT:none>')<EOL>ticks = list( self.get_major_ticks() ) <EOL>ticks.extend( self.get_minor_ticks() )<EOL>if position == '<STR_LIT:right>':<EOL><INDENT>self.set_offset_position('<STR_LIT:right>')<EOL>for t in ticks:<EOL><INDENT>t.tick1On = False<EOL>t.tick2On = True<EOL>t.label1On = False<EOL>t.label2On = True<EOL><DEDENT><DEDENT>elif position == '<STR_LIT:left>':<EOL><INDENT>self.set_offset_position('<STR_LIT:left>')<EOL>for t in ticks:<EOL><INDENT>t.tick1On = True<EOL>t.tick2On = False<EOL>t.label1On = True<EOL>t.label2On = False<EOL><DEDENT><DEDENT>elif position == '<STR_LIT:default>':<EOL><INDENT>self.set_offset_position('<STR_LIT:left>')<EOL>for t in ticks:<EOL><INDENT>t.tick1On = True<EOL>t.tick2On = True<EOL>t.label1On = True<EOL>t.label2On = False<EOL><DEDENT><DEDENT>elif position == '<STR_LIT:none>':<EOL><INDENT>for t in ticks:<EOL><INDENT>t.tick1On = False<EOL>t.tick2On = False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.set_offset_position('<STR_LIT:left>')<EOL>for t in ticks:<EOL><INDENT>t.tick1On = True<EOL>t.tick2On = True<EOL><DEDENT><DEDENT>

Set the ticks position (left, right, both or default)
both sets the ticks to appear on both positions, but
does not change the tick labels.
default resets the tick positions to the default:
ticks on both positions, labels on the left.

ACCEPTS: [ 'left' | 'right' | 'both' | 'default' | 'none' ]


self.set_ticks_position('<STR_LIT:right>')<EOL>


self.set_ticks_position('<STR_LIT:left>')<EOL>


majt=self.majorTicks[<NUM_LIT:0>]<EOL>mT=self.minorTicks[<NUM_LIT:0>]<EOL>majorRight=(not majt.tick1On) and majt.tick2On and (not majt.label1On) and majt.label2On<EOL>minorRight=(not mT.tick1On) and mT.tick2On and (not mT.label1On) and mT.label2On<EOL>if majorRight and minorRight: return '<STR_LIT:right>'<EOL>majorLeft=majt.tick1On and (not majt.tick2On) and majt.label1On and (not majt.label2On)<EOL>minorLeft=mT.tick1On and (not mT.tick2On) and mT.label1On and (not mT.label2On)<EOL>if majorLeft and minorLeft: return '<STR_LIT:left>'<EOL>majorDefault=majt.tick1On and majt.tick2On and majt.label1On and (not majt.label2On)<EOL>minorDefault=mT.tick1On and mT.tick2On and mT.label1On and (not mT.label2On)<EOL>if majorDefault and minorDefault: return '<STR_LIT:default>'<EOL>return '<STR_LIT>'<EOL>

Return the ticks position (left, right, both or unknown)


return self.axes.viewLim.intervaly<EOL>


return self.axes.dataLim.intervaly<EOL>


if ignore:<EOL><INDENT>self.axes.dataLim.intervaly = vmin, vmax<EOL><DEDENT>else:<EOL><INDENT>Vmin, Vmax = self.get_data_interval()<EOL>self.axes.dataLim.intervaly = min(vmin, Vmin), max(vmax, Vmax)<EOL><DEDENT>


if ((len(key) != <NUM_LIT:2>) or<EOL>(not isinstance(key[<NUM_LIT:0>], slice)) or<EOL>(not isinstance(key[<NUM_LIT:1>], slice))):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>x0 = key[<NUM_LIT:1>].start<EOL>x1 = key[<NUM_LIT:1>].stop<EOL>xstep = key[<NUM_LIT:1>].step<EOL>if not isinstance(xstep, complex) or int(xstep.real) != xstep.real:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>xstep = int(xstep.imag)<EOL>y0 = key[<NUM_LIT:0>].start<EOL>y1 = key[<NUM_LIT:0>].stop<EOL>ystep = key[<NUM_LIT:0>].step<EOL>if not isinstance(ystep, complex) or int(ystep.real) != ystep.real:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>ystep = int(ystep.imag)<EOL>return x0, x1, xstep, y0, y1, ystep<EOL>

Convert a 2-tuple of slices to start,stop,steps for x and y.

    key -- (slice(ystart,ystop,ystep), slice(xtart, xstop, xstep))

    For now, the only accepted step values are imaginary integers (interpreted
    in the same way numpy.mgrid, etc. do).


def quality(func, mesh, interpolator='<STR_LIT>', n=<NUM_LIT>):

fz = func(mesh.x, mesh.y)<EOL>tri = Triangulation(mesh.x, mesh.y)<EOL>intp = getattr(tri, interpolator+'<STR_LIT>')(fz, bbox=(<NUM_LIT:0.>,<NUM_LIT:1.>,<NUM_LIT:0.>,<NUM_LIT:1.>))<EOL>Y, X = np.mgrid[<NUM_LIT:0>:<NUM_LIT:1>:complex(<NUM_LIT:0>,n),<NUM_LIT:0>:<NUM_LIT:1>:complex(<NUM_LIT:0>,n)]<EOL>Z = func(X, Y)<EOL>iz = intp[<NUM_LIT:0>:<NUM_LIT:1>:complex(<NUM_LIT:0>,n),<NUM_LIT:0>:<NUM_LIT:1>:complex(<NUM_LIT:0>,n)]<EOL>numgood = n*n<EOL>SE = (Z - iz)**<NUM_LIT:2><EOL>SSE = np.sum(SE.flat)<EOL>meanZ = np.sum(Z.flat) / numgood<EOL>SM = (Z - meanZ)**<NUM_LIT:2><EOL>SSM = np.sum(SM.flat)<EOL>r2 = <NUM_LIT:1.0> - SSE/SSM<EOL>print(func.__name__, r2, SSE, SSM, numgood)<EOL>return r2<EOL>

Compute a quality factor (the quantity r**2 from TOMS792).

    interpolator must be in ('linear', 'nn').


<EOL>j_sorted = np.lexsort(keys=(self.x, self.y))<EOL>mask_unique = np.hstack([<EOL>True,<EOL>(np.diff(self.x[j_sorted]) != <NUM_LIT:0>) | (np.diff(self.y[j_sorted]) != <NUM_LIT:0>),<EOL>])<EOL>return j_sorted[mask_unique]<EOL>

Generate index array that picks out unique x,y points.

        This appears to be required by the underlying delaunay triangulation
        code.


Extract the convex hull from the triangulation information.

        The output will be a list of point_id's in counter-clockwise order
        forming the convex hull of the data set.


def linear_interpolator(self, z, default_value=np.nan):

z = np.asarray(z, dtype=np.float64)<EOL>if z.shape != self.old_shape:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if self.j_unique is not None:<EOL><INDENT>z = z[self.j_unique]<EOL><DEDENT>return LinearInterpolator(self, z, default_value)<EOL>

Get an object which can interpolate within the convex hull by
        assigning a plane to each triangle.

        z -- an array of floats giving the known function values at each point
          in the triangulation.


def nn_interpolator(self, z, default_value=np.nan):

z = np.asarray(z, dtype=np.float64)<EOL>if z.shape != self.old_shape:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if self.j_unique is not None:<EOL><INDENT>z = z[self.j_unique]<EOL><DEDENT>return NNInterpolator(self, z, default_value)<EOL>

Get an object which can interpolate within the convex hull by
        the natural neighbors method.

        z -- an array of floats giving the known function values at each point
          in the triangulation.


g = {}<EOL>for i, j in self.edge_db:<EOL><INDENT>s = g.setdefault(i, set())<EOL>s.add(j)<EOL>s = g.setdefault(j, set())<EOL>s.add(i)<EOL><DEDENT>return g<EOL>

Return a graph of node_id's pointing to node_id's.

        The arcs of the graph correspond to the edges in the triangulation.

        {node_id: set([node_id, ...]), ...}


def __init__(self, majloc=None, minloc=None,<EOL>majfmt=None, minfmt=None, label=None):

self.majloc = majloc<EOL>self.minloc = minloc<EOL>self.majfmt = majfmt<EOL>self.minfmt = minfmt<EOL>self.label = label<EOL>

majloc and minloc: TickLocators for the major and minor ticks
majfmt and minfmt: TickFormatters for the major and minor ticks
label: the default axis label

If any of the above are None, the axis will simply use the default


return None<EOL>

return an units.AxisInfo instance for unit


return None<EOL>


return obj<EOL>

convert obj using unit.  If obj is a sequence, return the
converted sequence.  The ouput must be a sequence of scalars
that can be used by the numpy array layer


if iterable(x):<EOL><INDENT>for thisx in x:<EOL><INDENT>return is_numlike(thisx)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return is_numlike(x)<EOL><DEDENT>

The matplotlib datalim, autoscaling, locators etc work with
scalars which are the units converted to floats given the
current unit.  The converter may be passed these floats, or
arrays of them, even when units are set.  Derived conversion
interfaces may opt to pass plain-ol unitless numbers through
the conversion interface and this is a helper function for
them.


if not len(self): return None <EOL>converter = None<EOL>classx = getattr(x, '<STR_LIT>', None)<EOL>if classx is not None:<EOL><INDENT>converter = self.get(classx)<EOL><DEDENT>if converter is None and iterable(x):<EOL><INDENT>if isinstance(x, np.ndarray) and x.dtype != np.object:<EOL><INDENT>return None<EOL><DEDENT>for thisx in x:<EOL><INDENT>converter = self.get_converter( thisx )<EOL>return converter<EOL><DEDENT><DEDENT>return converter<EOL>

get the converter interface instance for x, or None


try: p + '<STR_LIT>'  <EOL>except TypeError: return False<EOL>try:<EOL><INDENT>t = tempfile.TemporaryFile(dir=p)<EOL>t.write('<STR_LIT:1>')<EOL>t.close()<EOL><DEDENT>except OSError: return False<EOL>else: return True<EOL>

p is a string pointing to a putative writable dir -- return True p
is such a string, else False


if a:<EOL><INDENT>a = distutils.version.LooseVersion(a)<EOL>b = distutils.version.LooseVersion(b)<EOL>if a>=b: return True<EOL>else: return False<EOL><DEDENT>else: return False<EOL>

return True if a is greater than or equal to b


path='<STR_LIT>'<EOL>try:<EOL><INDENT>path=os.path.expanduser("<STR_LIT>")<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>if not os.path.isdir(path):<EOL><INDENT>for evar in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>path = os.environ[evar]<EOL>if os.path.isdir(path):<EOL><INDENT>break<EOL><DEDENT><DEDENT>except: pass<EOL><DEDENT><DEDENT>if path:<EOL><INDENT>return path<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>

Find user's home directory if possible.
    Otherwise raise error.

    :see:  http://mail.python.org/pipermail/python-list/2005-February/263921.html


configdir = os.environ.get('<STR_LIT>')<EOL>if configdir is not None:<EOL><INDENT>if not _is_writable_dir(configdir):<EOL><INDENT>raise RuntimeError('<STR_LIT>'%configdir)<EOL><DEDENT>return configdir<EOL><DEDENT>h = get_home()<EOL>p = os.path.join(get_home(), '<STR_LIT>')<EOL>if os.path.exists(p):<EOL><INDENT>if not _is_writable_dir(p):<EOL><INDENT>raise RuntimeError("<STR_LIT>"% (h, h))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not _is_writable_dir(h):<EOL><INDENT>raise RuntimeError("<STR_LIT>"%h)<EOL><DEDENT>os.mkdir(p)<EOL><DEDENT>return p<EOL>

Return the string representing the configuration dir.

default is HOME/.matplotlib.  you can override this with the
MPLCONFIGDIR environment variable


if '<STR_LIT>' in os.environ:<EOL><INDENT>path = os.environ['<STR_LIT>']<EOL>if not os.path.isdir(path):<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>return path<EOL><DEDENT>path = os.sep.join([os.path.dirname(__file__), '<STR_LIT>'])<EOL>if os.path.isdir(path): return path<EOL>import matplotlib.afm<EOL>path = os.sep.join([os.path.dirname(matplotlib.afm.__file__), '<STR_LIT>'])<EOL>if os.path.isdir(path): return path<EOL>if getattr(sys,'<STR_LIT>',None):<EOL><INDENT>path = os.path.join(os.path.split(sys.path[<NUM_LIT:0>])[<NUM_LIT:0>], '<STR_LIT>')<EOL>if os.path.isdir(path): return path<EOL>else:<EOL><INDENT>path = os.path.join(os.path.split(os.path.split(sys.path[<NUM_LIT:0>])[<NUM_LIT:0>])[<NUM_LIT:0>],<EOL>'<STR_LIT>')<EOL><DEDENT>if os.path.isdir(path): return path<EOL>else:<EOL><INDENT>path = os.path.join(sys.path[<NUM_LIT:0>], '<STR_LIT>')<EOL>if os.path.isdir(path): return path<EOL><DEDENT><DEDENT>raise RuntimeError('<STR_LIT>')<EOL>


datadir = os.path.join(get_data_path(), '<STR_LIT>')<EOL>fullpath = os.path.join(datadir, fname)<EOL>if not os.path.exists(fullpath):<EOL><INDENT>raise IOError('<STR_LIT>'%(<EOL>fname, datadir))<EOL><DEDENT>return file(fullpath, '<STR_LIT:rb>')<EOL>

return a filehandle to one of the example files in mpl-data/example

*fname*
    the name of one of the files in mpl-data/example


oldname = os.path.join( os.getcwd(), '<STR_LIT>')<EOL>if os.path.exists(oldname):<EOL><INDENT>print("""<STR_LIT>""", file=sys.stderr)<EOL>shutil.move('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>home = get_home()<EOL>oldname = os.path.join( home, '<STR_LIT>')<EOL>if os.path.exists(oldname):<EOL><INDENT>configdir = get_configdir()<EOL>newname = os.path.join(configdir, '<STR_LIT>')<EOL>print("""<STR_LIT>"""%(oldname, newname), file=sys.stderr)<EOL>shutil.move(oldname, newname)<EOL><DEDENT>fname = os.path.join( os.getcwd(), '<STR_LIT>')<EOL>if os.path.exists(fname): return fname<EOL>if '<STR_LIT>' in os.environ:<EOL><INDENT>path =  os.environ['<STR_LIT>']<EOL>if os.path.exists(path):<EOL><INDENT>fname = os.path.join(path, '<STR_LIT>')<EOL>if os.path.exists(fname):<EOL><INDENT>return fname<EOL><DEDENT><DEDENT><DEDENT>fname = os.path.join(get_configdir(), '<STR_LIT>')<EOL>if os.path.exists(fname): return fname<EOL>path =  get_data_path() <EOL>fname = os.path.join(path, '<STR_LIT>')<EOL>if not os.path.exists(fname):<EOL><INDENT>warnings.warn('<STR_LIT>')<EOL><DEDENT>return fname<EOL>

Return the path to the rc file

Search order:

 * current working dir
 * environ var MATPLOTLIBRC
 * HOME/.matplotlib/matplotlibrc
 * MATPLOTLIBDATA/matplotlibrc


fname = matplotlib_fname()<EOL>if not os.path.exists(fname):<EOL><INDENT>message = '<STR_LIT>'<EOL>ret = RcParams([ (key, default) for key, (default, converter) indefaultParams.items() ])<EOL>warnings.warn(message)<EOL>return ret<EOL><DEDENT>cnt = <NUM_LIT:0><EOL>rc_temp = {}<EOL>for line in file(fname):<EOL><INDENT>cnt += <NUM_LIT:1><EOL>strippedline = line.split('<STR_LIT:#>',<NUM_LIT:1>)[<NUM_LIT:0>].strip()<EOL>if not strippedline: continue<EOL>tup = strippedline.split('<STR_LIT::>',<NUM_LIT:1>)<EOL>if len(tup) !=<NUM_LIT:2>:<EOL><INDENT>warnings.warn('<STR_LIT>'%(cnt, line, fname))<EOL>continue<EOL><DEDENT>key, val = tup<EOL>key = key.strip()<EOL>val = val.strip()<EOL>if key in rc_temp:<EOL><INDENT>warnings.warn('<STR_LIT>'%(fname,cnt))<EOL><DEDENT>rc_temp[key] = (val, line, cnt)<EOL><DEDENT>ret = RcParams([ (key, default) for key, (default, converter) indefaultParams.items() ])<EOL>for key in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if key in rc_temp:<EOL><INDENT>val, line, cnt = rc_temp.pop(key)<EOL>if fail_on_error:<EOL><INDENT>ret[key] = val <EOL><DEDENT>else:<EOL><INDENT>try: ret[key] = val <EOL>except Exception as msg:<EOL><INDENT>warnings.warn('<STR_LIT>' % (val, cnt, line, fname, msg))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>verbose.set_level(ret['<STR_LIT>'])<EOL>verbose.set_fileo(ret['<STR_LIT>'])<EOL>for key, (val, line, cnt) in rc_temp.items():<EOL><INDENT>if key in defaultParams:<EOL><INDENT>if fail_on_error:<EOL><INDENT>ret[key] = val <EOL><DEDENT>else:<EOL><INDENT>try: ret[key] = val <EOL>except Exception as msg:<EOL><INDENT>warnings.warn('<STR_LIT>' % (val, cnt, line, fname, msg))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>print("""<STR_LIT>""" % (key, cnt, fname), file=sys.stderr)<EOL><DEDENT><DEDENT>if ret['<STR_LIT>'] is None:<EOL><INDENT>ret['<STR_LIT>'] = get_data_path()<EOL><DEDENT>if not ret['<STR_LIT>'] == ['<STR_LIT>']:<EOL><INDENT>verbose.report(

Return the default params updated from the values in the rc file


aliases = {<EOL>'<STR_LIT>'  : '<STR_LIT>',<EOL>'<STR_LIT>'  : '<STR_LIT>',<EOL>'<STR_LIT:c>'   : '<STR_LIT>',<EOL>'<STR_LIT>'  : '<STR_LIT>',<EOL>'<STR_LIT>'  : '<STR_LIT>',<EOL>'<STR_LIT>' : '<STR_LIT>',<EOL>'<STR_LIT>'  : '<STR_LIT>',<EOL>}<EOL>if is_string_like(group):<EOL><INDENT>group = (group,)<EOL><DEDENT>for g in group:<EOL><INDENT>for k,v in list(kwargs.items()):<EOL><INDENT>name = aliases.get(k) or k<EOL>key = '<STR_LIT>' % (g, name)<EOL>if key not in rcParams:<EOL><INDENT>raise KeyError('<STR_LIT>' %<EOL>(key, g, name))<EOL><DEDENT>rcParams[key] = v<EOL><DEDENT><DEDENT>

Set the current rc params.  Group is the grouping for the rc, eg.
for ``lines.linewidth`` the group is ``lines``, for
``axes.facecolor``, the group is ``axes``, and so on.  Group may
also be a list or tuple of group names, eg. (*xtick*, *ytick*).
*kwargs* is a dictionary attribute name/value pairs, eg::

  rc('lines', linewidth=2, color='r')

sets the current rc params and is equivalent to::

  rcParams['lines.linewidth'] = 2
  rcParams['lines.color'] = 'r'

The following aliases are available to save typing for interactive
users:

=====   =================
Alias   Property
=====   =================
'lw'    'linewidth'
'ls'    'linestyle'
'c'     'color'
'fc'    'facecolor'
'ec'    'edgecolor'
'mew'   'markeredgewidth'
'aa'    'antialiased'
=====   =================

Thus you could abbreviate the above rc command as::

      rc('lines', lw=2, c='r')

Note you can use python's kwargs dictionary facility to store
dictionaries of default parameters.  Eg, you can customize the
font rc as follows::

  font = {'family' : 'monospace',
          'weight' : 'bold',
          'size'   : 'larger'}

  rc('font', **font)  # pass in the font dict as kwargs

This enables you to easily switch between several configurations.
Use :func:`~matplotlib.pyplot.rcdefaults` to restore the default
rc params after changes.


rcParams.update(rcParamsDefault)<EOL>

Restore the default rc params - the ones that were created at
matplotlib load time.


if '<STR_LIT>' in sys.modules:<EOL><INDENT>if warn: warnings.warn(_use_error_msg)<EOL>return<EOL><DEDENT>arg = arg.lower()<EOL>if arg.startswith('<STR_LIT>'):<EOL><INDENT>name = arg<EOL><DEDENT>else:<EOL><INDENT>be_parts = arg.split('<STR_LIT:.>')<EOL>name = validate_backend(be_parts[<NUM_LIT:0>])<EOL><DEDENT>rcParams['<STR_LIT>'] = name<EOL>if name == '<STR_LIT>' and len(be_parts) > <NUM_LIT:1>:<EOL><INDENT>rcParams['<STR_LIT>'] = validate_cairo_format(be_parts[<NUM_LIT:1>])<EOL><DEDENT>

Set the matplotlib backend to one of the known backends.

The argument is case-insensitive.  For the Cairo backend,
the argument can have an extension to indicate the type of
output.  Example:

    use('cairo.pdf')

will specify a default of pdf output generated by Cairo.

Note: this function must be called *before* importing pylab for
the first time; or, if you are not using pylab, it must be called
before importing matplotlib.backends.  If warn is True, a warning
is issued if you try and callthis after pylab or pyplot have been
loaded.  In certain black magic use cases, eg
pyplot.switch_backends, we are doing the reloading necessary to
make the backend switch work (in some cases, eg pure image
backends) so one can set warn=False to supporess the warnings


return rcParams['<STR_LIT>']<EOL>


rcParams['<STR_LIT>'] = b<EOL>

Set interactive mode to boolean b.

If b is True, then draw after every plotting command, eg, after xlabel


b = rcParams['<STR_LIT>']<EOL>return b<EOL>


if rcParams['<STR_LIT>'] != '<STR_LIT>':<EOL><INDENT>return False<EOL><DEDENT>return rcParams['<STR_LIT>']<EOL>

Return true if focus maintenance under TkAgg on win32 is on.
     This currently works only for python.exe and IPython.exe.
     Both IDLE and Pythonwin.exe fail badly when tk_window_focus is on.


if self._commandLineVerbose is not None:<EOL><INDENT>level = self._commandLineVerbose<EOL><DEDENT>if level not in self.levels:<EOL><INDENT>raise ValueError('<STR_LIT>'%(level, self.levels))<EOL><DEDENT>self.level = level<EOL>

set the verbosity to one of the Verbose.levels strings


if self.ge(level):<EOL><INDENT>print(s, file=self.fileo)<EOL>return True<EOL><DEDENT>return False<EOL>

print message s to self.fileo if self.level>=level.  Return
value indicates whether a message was issued


def wrap(self, fmt, func, level='<STR_LIT>', always=True):

assert callable(func)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>ret = func(*args, **kwargs)<EOL>if (always or not wrapper._spoke):<EOL><INDENT>spoke = self.report(fmt%ret, level)<EOL>if not wrapper._spoke: wrapper._spoke = spoke<EOL><DEDENT>return ret<EOL><DEDENT>wrapper._spoke = False<EOL>wrapper.__doc__ = func.__doc__<EOL>return wrapper<EOL>

return a callable function that wraps func and reports it
output through the verbose handler if current verbosity level
is higher than level

if always is True, the report will occur on every function
call; otherwise only on the first time the function is called


return self.vald[self.level]>=self.vald[level]<EOL>


pass<EOL>

Open a grouping element with label *s*. Is only currently used by
:mod:`~matplotlib.backends.backend_svg`


pass<EOL>

Close a grouping element with label *s*
Is only currently used by :mod:`~matplotlib.backends.backend_svg`


def draw_path(self, gc, path, transform, rgbFace=None):

raise NotImplementedError<EOL>

Draws a :class:`~matplotlib.path.Path` instance using the
given affine transform.


def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):

tpath = trans.transform_path(path)<EOL>for vertices, codes in tpath.iter_segments():<EOL><INDENT>if len(vertices):<EOL><INDENT>x,y = vertices[-<NUM_LIT:2>:]<EOL>self.draw_path(gc, marker_path,<EOL>marker_trans + transforms.Affine2D().translate(x, y),<EOL>rgbFace)<EOL><DEDENT><DEDENT>

Draws a marker at each of the vertices in path.  This includes
all vertices, including control points on curves.  To avoid
that behavior, those vertices should be removed before calling
this function.

*gc*
    the :class:`GraphicsContextBase` instance

*marker_trans*
    is an affine transform applied to the marker.

*trans*
     is an affine transform applied to the path.

This provides a fallback implementation of draw_markers that
makes multiple calls to :meth:`draw_path`.  Some backends may
want to override this method in order to draw the marker only
once and reuse it multiple times.


def draw_path_collection(self, master_transform, cliprect, clippath,<EOL>clippath_trans, paths, all_transforms, offsets,<EOL>offsetTrans, facecolors, edgecolors, linewidths,<EOL>linestyles, antialiaseds, urls):

path_ids = []<EOL>for path, transform in self._iter_collection_raw_paths(<EOL>master_transform, paths, all_transforms):<EOL><INDENT>path_ids.append((path, transform))<EOL><DEDENT>for xo, yo, path_id, gc, rgbFace in self._iter_collection(<EOL>path_ids, cliprect, clippath, clippath_trans,<EOL>offsets, offsetTrans, facecolors, edgecolors,<EOL>linewidths, linestyles, antialiaseds, urls):<EOL><INDENT>path, transform = path_id<EOL>transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo)<EOL>self.draw_path(gc, path, transform, rgbFace)<EOL><DEDENT>

Draws a collection of paths, selecting drawing properties from
the lists *facecolors*, *edgecolors*, *linewidths*,
*linestyles* and *antialiaseds*. *offsets* is a list of
offsets to apply to each of the paths.  The offsets in
*offsets* are first transformed by *offsetTrans* before
being applied.

This provides a fallback implementation of
:meth:`draw_path_collection` that makes multiple calls to
draw_path.  Some backends may want to override this in order
to render each set of path data only once, and then reference
that path multiple times with the different offsets, colors,
styles etc.  The generator methods
:meth:`_iter_collection_raw_paths` and
:meth:`_iter_collection` are provided to help with (and
standardize) the implementation across backends.  It is highly
recommended to use those generators, so that changes to the
behavior of :meth:`draw_path_collection` can be made globally.


def draw_quad_mesh(self, master_transform, cliprect, clippath,<EOL>clippath_trans, meshWidth, meshHeight, coordinates,<EOL>offsets, offsetTrans, facecolors, antialiased,<EOL>showedges):

from matplotlib.collections import QuadMesh<EOL>paths = QuadMesh.convert_mesh_to_paths(<EOL>meshWidth, meshHeight, coordinates)<EOL>if showedges:<EOL><INDENT>edgecolors = np.array([[<NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:1.0>]], np.float_)<EOL>linewidths = np.array([<NUM_LIT:1.0>], np.float_)<EOL><DEDENT>else:<EOL><INDENT>edgecolors = facecolors<EOL>linewidths = np.array([<NUM_LIT:0.0>], np.float_)<EOL><DEDENT>return self.draw_path_collection(<EOL>master_transform, cliprect, clippath, clippath_trans,<EOL>paths, [], offsets, offsetTrans, facecolors, edgecolors,<EOL>linewidths, [], [antialiased], [None])<EOL>

This provides a fallback implementation of
:meth:`draw_quad_mesh` that generates paths and then calls
:meth:`draw_path_collection`.


def _iter_collection_raw_paths(self, master_transform, paths, all_transforms):

Npaths      = len(paths)<EOL>Ntransforms = len(all_transforms)<EOL>N           = max(Npaths, Ntransforms)<EOL>if Npaths == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>transform = transforms.IdentityTransform()<EOL>for i in range(N):<EOL><INDENT>path = paths[i % Npaths]<EOL>if Ntransforms:<EOL><INDENT>transform = all_transforms[i % Ntransforms]<EOL><DEDENT>yield path, transform + master_transform<EOL><DEDENT>

This is a helper method (along with :meth:`_iter_collection`) to make
it easier to write a space-efficent :meth:`draw_path_collection`
implementation in a backend.

This method yields all of the base path/transform
combinations, given a master transform, a list of paths and
list of transforms.

The arguments should be exactly what is passed in to
:meth:`draw_path_collection`.

The backend should take each yielded path and transform and
create an object that can be referenced (reused) later.


def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans,<EOL>offsets, offsetTrans, facecolors, edgecolors,<EOL>linewidths, linestyles, antialiaseds, urls):

Npaths      = len(path_ids)<EOL>Noffsets    = len(offsets)<EOL>N           = max(Npaths, Noffsets)<EOL>Nfacecolors = len(facecolors)<EOL>Nedgecolors = len(edgecolors)<EOL>Nlinewidths = len(linewidths)<EOL>Nlinestyles = len(linestyles)<EOL>Naa         = len(antialiaseds)<EOL>Nurls       = len(urls)<EOL>if (Nfacecolors == <NUM_LIT:0> and Nedgecolors == <NUM_LIT:0>) or Npaths == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if Noffsets:<EOL><INDENT>toffsets = offsetTrans.transform(offsets)<EOL><DEDENT>gc = self.new_gc()<EOL>gc.set_clip_rectangle(cliprect)<EOL>if clippath is not None:<EOL><INDENT>clippath = transforms.TransformedPath(clippath, clippath_trans)<EOL>gc.set_clip_path(clippath)<EOL><DEDENT>if Nfacecolors == <NUM_LIT:0>:<EOL><INDENT>rgbFace = None<EOL><DEDENT>if Nedgecolors == <NUM_LIT:0>:<EOL><INDENT>gc.set_linewidth(<NUM_LIT:0.0>)<EOL><DEDENT>xo, yo = <NUM_LIT:0>, <NUM_LIT:0><EOL>for i in range(N):<EOL><INDENT>path_id = path_ids[i % Npaths]<EOL>if Noffsets:<EOL><INDENT>xo, yo = toffsets[i % Noffsets]<EOL><DEDENT>if Nfacecolors:<EOL><INDENT>rgbFace = facecolors[i % Nfacecolors]<EOL><DEDENT>if Nedgecolors:<EOL><INDENT>gc.set_foreground(edgecolors[i % Nedgecolors])<EOL>if Nlinewidths:<EOL><INDENT>gc.set_linewidth(linewidths[i % Nlinewidths])<EOL><DEDENT>if Nlinestyles:<EOL><INDENT>gc.set_dashes(*linestyles[i % Nlinestyles])<EOL><DEDENT><DEDENT>if rgbFace is not None and len(rgbFace)==<NUM_LIT:4>:<EOL><INDENT>gc.set_alpha(rgbFace[-<NUM_LIT:1>])<EOL>rgbFace = rgbFace[:<NUM_LIT:3>]<EOL><DEDENT>gc.set_antialiased(antialiaseds[i % Naa])<EOL>if Nurls:<EOL><INDENT>gc.set_url(urls[i % Nurls])<EOL><DEDENT>yield xo, yo, path_id, gc, rgbFace<EOL><DEDENT>

This is a helper method (along with
:meth:`_iter_collection_raw_paths`) to make it easier to write
a space-efficent :meth:`draw_path_collection` implementation in a
backend.

This method yields all of the path, offset and graphics
context combinations to draw the path collection.  The caller
should already have looped over the results of
:meth:`_iter_collection_raw_paths` to draw this collection.

The arguments should be the same as that passed into
:meth:`draw_path_collection`, with the exception of
*path_ids*, which is a list of arbitrary objects that the
backend will use to reference one of the paths created in the
:meth:`_iter_collection_raw_paths` stage.

Each yielded result is of the form::

   xo, yo, path_id, gc, rgbFace

where *xo*, *yo* is an offset; *path_id* is one of the elements of
*path_ids*; *gc* is a graphics context and *rgbFace* is a color to
use for filling the path.


return <NUM_LIT:1.0><EOL>

Get the factor by which to magnify images passed to :meth:`draw_image`.
Allows a backend to have images at a different resolution to other
artists.


def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):

raise NotImplementedError<EOL>

Draw the image instance into the current axes;

*x*
    is the distance in pixels from the left hand side of the canvas.

*y*
    the distance from the origin.  That is, if origin is
    upper, y is the distance from top.  If origin is lower, y
    is the distance from bottom

*im*
    the :class:`matplotlib._image.Image` instance

*bbox*
    a :class:`matplotlib.transforms.Bbox` instance for clipping, or
    None


return False<EOL>

overwrite this method for renderers that do not necessarily
want to rescale and composite raster images. (like SVG)


def draw_text(self, gc, x, y, s, prop, angle, ismath=False):

raise NotImplementedError<EOL>

Draw the text instance

*gc*
    the :class:`GraphicsContextBase` instance

*x*
    the x location of the text in display coords

*y*
    the y location of the text in display coords

*s*
     a :class:`matplotlib.text.Text` instance

*prop*
  a :class:`matplotlib.font_manager.FontProperties` instance

*angle*
    the rotation angle in degrees

**backend implementers note**

When you are trying to determine if you have gotten your bounding box
right (which is what enables the text layout/alignment to work
properly), it helps to change the line in text.py::

    if 0: bbox_artist(self, renderer)

to if 1, and then the actual bounding box will be blotted along with
your text.


return True<EOL>

Return true if y small numbers are top for renderer Is used
for drawing text (:mod:`matplotlib.text`) and images
(:mod:`matplotlib.image`) only


return <NUM_LIT:1>, <NUM_LIT:1><EOL>

return the canvas width and height in display coords


if self._texmanager is None:<EOL><INDENT>from matplotlib.texmanager import TexManager<EOL>self._texmanager = TexManager()<EOL><DEDENT>return self._texmanager<EOL>

return the :class:`matplotlib.texmanager.TexManager` instance


def get_text_width_height_descent(self, s, prop, ismath):

raise NotImplementedError<EOL>

get the width and height, and the offset from the bottom to the
baseline (descent), in display coords of the string s with
:class:`~matplotlib.font_manager.FontProperties` prop


return GraphicsContextBase()<EOL>

Return an instance of a :class:`GraphicsContextBase`


return points<EOL>

Convert points to display units

*points*
    a float or a numpy array of float

return points converted to pixels

You need to override this function (unless your backend
doesn't have a dpi, eg, postscript or svg).  Some imaging
systems assume some value for pixels per inch::

    points to pixels = points * pixels_per_inch/72.0 * dpi/72.0


self._alpha = gc._alpha<EOL>self._antialiased = gc._antialiased<EOL>self._capstyle = gc._capstyle<EOL>self._cliprect = gc._cliprect<EOL>self._clippath = gc._clippath<EOL>self._dashes = gc._dashes<EOL>self._joinstyle = gc._joinstyle<EOL>self._linestyle = gc._linestyle<EOL>self._linewidth = gc._linewidth<EOL>self._rgb = gc._rgb<EOL>self._hatch = gc._hatch<EOL>self._url = gc._url<EOL>self._snap = gc._snap<EOL>


return self._alpha<EOL>

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


return self._antialiased<EOL>

Return true if the object should try to do antialiased rendering


return self._capstyle<EOL>

Return the capstyle as a string in ('butt', 'round', 'projecting')


return self._cliprect<EOL>

Return the clip rectangle as a :class:`~matplotlib.transforms.Bbox` instance


if self._clippath is not None:<EOL><INDENT>return self._clippath.get_transformed_path_and_affine()<EOL><DEDENT>return None, None<EOL>

Return the clip path in the form (path, transform), where path
is a :class:`~matplotlib.path.Path` instance, and transform is
an affine transform to apply to the path before clipping.


return self._dashes<EOL>

Return the dash information as an offset dashlist tuple.

The dash list is a even size list that gives the ink on, ink
off in pixels.

See p107 of to PostScript `BLUEBOOK
<http://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF>`_
for more info.

Default value is None


return self._joinstyle<EOL>

Return the line join style as one of ('miter', 'round', 'bevel')


return self._linestyle<EOL>

Return the linestyle: one of ('solid', 'dashed', 'dashdot',
'dotted').


return self._linewidth<EOL>

Return the line width in points as a scalar


return self._rgb<EOL>

returns a tuple of three floats from 0-1.  color can be a
matlab format string, a html hex color string, or a rgb tuple


return self._url<EOL>

returns a url if one is set, None otherwise


return self._snap<EOL>

returns the snap setting which may be:

  * True: snap vertices to the nearest pixel center

  * False: leave vertices as-is

  * None: (auto) If the path contains only rectilinear line
    segments, round to the nearest pixel center


self._alpha = alpha<EOL>

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


<EOL>if b: self._antialiased = <NUM_LIT:1><EOL>else: self._antialiased = <NUM_LIT:0><EOL>

True if object should be drawn with antialiased rendering


if cs in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>self._capstyle = cs<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % cs)<EOL><DEDENT>

Set the capstyle as a string in ('butt', 'round', 'projecting')


self._cliprect = rectangle<EOL>

Set the clip rectangle with sequence (left, bottom, width, height)


assert path is None or isinstance(path, transforms.TransformedPath)<EOL>self._clippath = path<EOL>

Set the clip path and transformation.  Path should be a
:class:`~matplotlib.transforms.TransformedPath` instance.


def set_dashes(self, dash_offset, dash_list):

self._dashes = dash_offset, dash_list<EOL>

Set the dash style for the gc.

*dash_offset*
    is the offset (usually 0).

*dash_list*
    specifies the on-off sequence as points.  ``(None, None)`` specifies a solid line


def set_foreground(self, fg, isRGB=False):

if isRGB:<EOL><INDENT>self._rgb = fg<EOL><DEDENT>else:<EOL><INDENT>self._rgb = colors.colorConverter.to_rgba(fg)<EOL><DEDENT>

Set the foreground color.  fg can be a matlab format string, a
html hex color string, an rgb unit tuple, or a float between 0
and 1.  In the latter case, grayscale is used.

The :class:`GraphicsContextBase` converts colors to rgb
internally.  If you know the color is rgb already, you can set
``isRGB=True`` to avoid the performace hit of the conversion


self._rgb = (frac, frac, frac)<EOL>

Set the foreground color to be a gray level with *frac*


if js in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>self._joinstyle = js<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % js)<EOL><DEDENT>

Set the join style to be one of ('miter', 'round', 'bevel')


self._linewidth = w<EOL>


try:<EOL><INDENT>offset, dashes = self.dashd[style]<EOL><DEDENT>except:<EOL><INDENT>raise ValueError('<STR_LIT>' % style)<EOL><DEDENT>self._linestyle = style<EOL>self.set_dashes(offset, dashes)<EOL>

Set the linestyle to be one of ('solid', 'dashed', 'dashdot',
'dotted').


self._url = url<EOL>

Sets the url for links in compatible backends


self._snap = snap<EOL>

Sets the snap setting which may be:

  * True: snap vertices to the nearest pixel center

  * False: leave vertices as-is

  * None: (auto) If the path contains only rectilinear line
    segments, round to the nearest pixel center


self._hatch = hatch<EOL>


return self._hatch<EOL>


def __init__(self, name, canvas, x, y,guiEvent=None):

Event.__init__(self, name, canvas,guiEvent=guiEvent)<EOL>self.x = x<EOL>self.y = y<EOL>if x is None or y is None:<EOL><INDENT>self.inaxes = None<EOL>self._update_enter_leave()<EOL>return<EOL><DEDENT>axes_list = [a for a in self.canvas.figure.get_axes() if a.in_axes(self)]<EOL>if len(axes_list) == <NUM_LIT:0>: <EOL><INDENT>self.inaxes = None<EOL>self._update_enter_leave()<EOL>return<EOL><DEDENT>elif (len(axes_list) > <NUM_LIT:1>): <EOL><INDENT>axCmp = lambda _x,_y: cmp(_x.zorder, _y.zorder)<EOL>axes_list.sort(axCmp)<EOL>self.inaxes = axes_list[-<NUM_LIT:1>] <EOL><DEDENT>else: <EOL><INDENT>self.inaxes = axes_list[<NUM_LIT:0>]<EOL><DEDENT>try:<EOL><INDENT>xdata, ydata = self.inaxes.transData.inverted().transform_point((x, y))<EOL><DEDENT>except ValueError:<EOL><INDENT>self.xdata  = None<EOL>self.ydata  = None<EOL><DEDENT>else:<EOL><INDENT>self.xdata  = xdata<EOL>self.ydata  = ydata<EOL><DEDENT>self._update_enter_leave()<EOL>

*x*, *y* in figure coords, 0,0 = bottom, left


if LocationEvent.lastevent is not None:<EOL><INDENT>last = LocationEvent.lastevent<EOL>if last.inaxes!=self.inaxes:<EOL><INDENT>if last.inaxes is not None:<EOL><INDENT>last.canvas.callbacks.process('<STR_LIT>', last)<EOL><DEDENT>if self.inaxes is not None:<EOL><INDENT>self.canvas.callbacks.process('<STR_LIT>', self)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if self.inaxes is not None:<EOL><INDENT>self.canvas.callbacks.process('<STR_LIT>', self)<EOL><DEDENT><DEDENT>LocationEvent.lastevent = self<EOL>

process the figure/axes enter leave events


def __init__(self, name, canvas, x, y, button=None, key=None,<EOL>step=<NUM_LIT:0>, guiEvent=None):

LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)<EOL>self.button = button<EOL>self.key = key<EOL>self.step = step<EOL>

x, y in figure coords, 0,0 = bottom, left
button pressed None, 1, 2, 3, 'up', 'down'


def sort_artists(artists):<EOL><INDENT>L = [ (h.zorder, h) for h in artists ]<EOL>L.sort()<EOL>return [ h for zorder, h in L ]<EOL><DEDENT>under = sort_artists(self.figure.hitlist(ev))<EOL>h = None<EOL>if under: h = under[-<NUM_LIT:1>]<EOL>while h:<EOL><INDENT>print("<STR_LIT>",h)<EOL>if h.remove():<EOL><INDENT>self.draw_idle()<EOL>break<EOL><DEDENT>parent = None<EOL>for p in under:<EOL><INDENT>if h in p.get_children():<EOL><INDENT>parent = p<EOL>break<EOL><DEDENT><DEDENT>h = parent<EOL><DEDENT>

Mouse event processor which removes the top artist
under the cursor.  Connect this to the 'mouse_press_event'
using::

    canvas.mpl_connect('mouse_press_event',canvas.onRemove)


if not hasattr(self,'<STR_LIT>'): self._active = dict()<EOL>under = self.figure.hitlist(ev)<EOL>enter = [a for a in under if a not in self._active]<EOL>leave = [a for a in self._active if a not in under]<EOL>print("<STR_LIT>","<STR_LIT:U+0020>".join([str(x) for x in under]))<EOL>for a in leave:<EOL><INDENT>if hasattr(a,'<STR_LIT>'):<EOL><INDENT>a.set_color(self._active[a])<EOL><DEDENT>elif hasattr(a,'<STR_LIT>'):<EOL><INDENT>a.set_edgecolor(self._active[a][<NUM_LIT:0>])<EOL>a.set_facecolor(self._active[a][<NUM_LIT:1>])<EOL><DEDENT>del self._active[a]<EOL><DEDENT>for a in enter:<EOL><INDENT>if hasattr(a,'<STR_LIT>'):<EOL><INDENT>self._active[a] = a.get_color()<EOL><DEDENT>elif hasattr(a,'<STR_LIT>'):<EOL><INDENT>self._active[a] = (a.get_edgecolor(),a.get_facecolor())<EOL><DEDENT>else: self._active[a] = None<EOL><DEDENT>for a in enter:<EOL><INDENT>if hasattr(a,'<STR_LIT>'):<EOL><INDENT>a.set_color('<STR_LIT>')<EOL><DEDENT>elif hasattr(a,'<STR_LIT>'):<EOL><INDENT>a.set_edgecolor('<STR_LIT>')<EOL>a.set_facecolor('<STR_LIT>')<EOL><DEDENT>else: self._active[a] = None<EOL><DEDENT>self.draw_idle()<EOL>

Mouse event processor which highlights the artists
under the cursor.  Connect this to the 'motion_notify_event'
using::

    canvas.mpl_connect('motion_notify_event',canvas.onHilite)


pass<EOL>

blit the canvas in bbox (default entire canvas)


pass<EOL>


s = '<STR_LIT>'<EOL>event = DrawEvent(s, self, renderer)<EOL>self.callbacks.process(s, event)<EOL>

This method will be call all functions connected to the
'draw_event' with a :class:`DrawEvent`


s = '<STR_LIT>'<EOL>event = ResizeEvent(s, self)<EOL>self.callbacks.process(s, event)<EOL>

This method will be call all functions connected to the
'resize_event' with a :class:`ResizeEvent`


def key_press_event(self, key, guiEvent=None):

self._key = key<EOL>s = '<STR_LIT>'<EOL>event = KeyEvent(s, self, key, self._lastx, self._lasty, guiEvent=guiEvent)<EOL>self.callbacks.process(s, event)<EOL>

This method will be call all functions connected to the
'key_press_event' with a :class:`KeyEvent`


def key_release_event(self, key, guiEvent=None):

s = '<STR_LIT>'<EOL>event = KeyEvent(s, self, key, self._lastx, self._lasty, guiEvent=guiEvent)<EOL>self.callbacks.process(s, event)<EOL>self._key = None<EOL>

This method will be call all functions connected to the
'key_release_event' with a :class:`KeyEvent`


def pick_event(self, mouseevent, artist, **kwargs):

s = '<STR_LIT>'<EOL>event = PickEvent(s, self, mouseevent, artist, **kwargs)<EOL>self.callbacks.process(s, event)<EOL>

This method will be called by artists who are picked and will
fire off :class:`PickEvent` callbacks registered listeners


def scroll_event(self, x, y, step, guiEvent=None):

if step >= <NUM_LIT:0>:<EOL><INDENT>self._button = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>self._button = '<STR_LIT>'<EOL><DEDENT>s = '<STR_LIT>'<EOL>mouseevent = MouseEvent(s, self, x, y, self._button, self._key,<EOL>step=step, guiEvent=guiEvent)<EOL>self.callbacks.process(s, mouseevent)<EOL>

Backend derived classes should call this function on any
scroll wheel event.  x,y are the canvas coords: 0,0 is lower,
left.  button and key are as defined in MouseEvent.

This method will be call all functions connected to the
'scroll_event' with a :class:`MouseEvent` instance.


def button_press_event(self, x, y, button, guiEvent=None):

self._button = button<EOL>s = '<STR_LIT>'<EOL>mouseevent = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent)<EOL>self.callbacks.process(s, mouseevent)<EOL>

Backend derived classes should call this function on any mouse
button press.  x,y are the canvas coords: 0,0 is lower, left.
button and key are as defined in :class:`MouseEvent`.

This method will be call all functions connected to the
'button_press_event' with a :class:`MouseEvent` instance.


def button_release_event(self, x, y, button, guiEvent=None):

s = '<STR_LIT>'<EOL>event = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent)<EOL>self.callbacks.process(s, event)<EOL>self._button = None<EOL>

Backend derived classes should call this function on any mouse
button release.

*x*
    the canvas coordinates where 0=left

*y*
    the canvas coordinates where 0=bottom

*guiEvent*
    the native UI event that generated the mpl event

This method will be call all functions connected to the
'button_release_event' with a :class:`MouseEvent` instance.


def motion_notify_event(self, x, y, guiEvent=None):

self._lastx, self._lasty = x, y<EOL>s = '<STR_LIT>'<EOL>event = MouseEvent(s, self, x, y, self._button, self._key,<EOL>guiEvent=guiEvent)<EOL>self.callbacks.process(s, event)<EOL>

Backend derived classes should call this function on any
motion-notify-event.

*x*
    the canvas coordinates where 0=left

*y*
    the canvas coordinates where 0=bottom

*guiEvent*
    the native UI event that generated the mpl event

This method will be call all functions connected to the
'motion_notify_event' with a :class:`MouseEvent` instance.


self.callbacks.process('<STR_LIT>', LocationEvent.lastevent)<EOL>LocationEvent.lastevent = None<EOL>

Backend derived classes should call this function when leaving
canvas

*guiEvent*
    the native UI event that generated the mpl event


event = Event('<STR_LIT>', self, guiEvent)<EOL>self.callbacks.process('<STR_LIT>', event)<EOL>

Backend derived classes should call this function when entering
canvas

*guiEvent*
    the native UI event that generated the mpl event


s = '<STR_LIT>'<EOL>event = IdleEvent(s, self, guiEvent=guiEvent)<EOL>self.callbacks.process(s, event)<EOL>


self.draw(*args, **kwargs)<EOL>

:meth:`draw` only if idle; defaults to draw but backends can overrride


pass<EOL>

Draw a cursor in the event.axes if inaxes is not None.  Use
native GUI drawing for efficiency if possible


return int(self.figure.bbox.width), int(self.figure.bbox.height)<EOL>

return the figure width and height in points or pixels
(depending on the backend), truncated to integers


def print_figure(self, filename, dpi=None, facecolor='<STR_LIT:w>', edgecolor='<STR_LIT:w>',<EOL>orientation='<STR_LIT>', format=None, **kwargs):

if format is None:<EOL><INDENT>if cbook.is_string_like(filename):<EOL><INDENT>format = os.path.splitext(filename)[<NUM_LIT:1>][<NUM_LIT:1>:]<EOL><DEDENT>if format is None or format == '<STR_LIT>':<EOL><INDENT>format = self.get_default_filetype()<EOL>if cbook.is_string_like(filename):<EOL><INDENT>filename = filename.rstrip('<STR_LIT:.>') + '<STR_LIT:.>' + format<EOL><DEDENT><DEDENT><DEDENT>format = format.lower()<EOL>method_name = '<STR_LIT>' % format<EOL>if (format not in self.filetypes or<EOL>not hasattr(self, method_name)):<EOL><INDENT>formats = list(self.filetypes.keys())<EOL>formats.sort()<EOL>raise ValueError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (format, '<STR_LIT:U+002CU+0020>'.join(formats)))<EOL><DEDENT>if dpi is None:<EOL><INDENT>dpi = rcParams['<STR_LIT>']<EOL><DEDENT>origDPI = self.figure.dpi<EOL>origfacecolor = self.figure.get_facecolor()<EOL>origedgecolor = self.figure.get_edgecolor()<EOL>self.figure.dpi = dpi<EOL>self.figure.set_facecolor(facecolor)<EOL>self.figure.set_edgecolor(edgecolor)<EOL>try:<EOL><INDENT>result = getattr(self, method_name)(<EOL>filename,<EOL>dpi=dpi,<EOL>facecolor=facecolor,<EOL>edgecolor=edgecolor,<EOL>orientation=orientation,<EOL>**kwargs)<EOL><DEDENT>finally:<EOL><INDENT>self.figure.dpi = origDPI<EOL>self.figure.set_facecolor(origfacecolor)<EOL>self.figure.set_edgecolor(origedgecolor)<EOL>self.figure.set_canvas(self)<EOL><DEDENT>return result<EOL>

Render the figure to hardcopy. Set the figure patch face and edge
colors.  This is useful because some of the GUIs have a gray figure
face color background and you'll probably want to override this on
hardcopy.

Arguments are:

*filename*
    can also be a file object on image backends

*orientation*
    only currently applies to PostScript printing.

*dpi*
    the dots per inch to save the figure in; if None, use savefig.dpi

*facecolor*
    the facecolor of the figure

*edgecolor*
    the edgecolor of the figure

*orientation*  '
    landscape' | 'portrait' (not supported on all backends)

*format*
    when set, forcibly set the file format to save to


if hasattr(self, "<STR_LIT>"):<EOL><INDENT>self.manager.set_window_title(title)<EOL><DEDENT>

Set the title text of the window containing the figure.  Note that
this has no effect if there is no window (eg, a PS backend).


newCanvas = FigureCanvasClass(self.figure)<EOL>return newCanvas<EOL>

instantiate an instance of FigureCanvasClass

This is used for backend switching, eg, to instantiate a
FigureCanvasPS from a FigureCanvasGTK.  Note, deep copying is
not done, so any changes to one of the instances (eg, setting
figure size or line props), will be reflected in the other


return self.callbacks.connect(s, func)<EOL>

Connect event with string *s* to *func*.  The signature of *func* is::

  def func(event)

where event is a :class:`matplotlib.backend_bases.Event`.  The
following events are recognized

- 'button_press_event'
- 'button_release_event'
- 'draw_event'
- 'key_press_event'
- 'key_release_event'
- 'motion_notify_event'
- 'pick_event'
- 'resize_event'
- 'scroll_event'

For the location events (button and key press/release), if the
mouse is over the axes, the variable ``event.inaxes`` will be
set to the :class:`~matplotlib.axes.Axes` the event occurs is
over, and additionally, the variables ``event.xdata`` and
``event.ydata`` will be defined.  This is the mouse location
in data coords.  See
:class:`~matplotlib.backend_bases.KeyEvent` and
:class:`~matplotlib.backend_bases.MouseEvent` for more info.

Return value is a connection id that can be used with
:meth:`~matplotlib.backend_bases.Event.mpl_disconnect`.

Example usage::

    def on_press(event):
        print 'you pressed', event.button, event.xdata, event.ydata

    cid = canvas.mpl_connect('button_press_event', on_press)


return self.callbacks.disconnect(cid)<EOL>

disconnect callback id cid

Example usage::

    cid = canvas.mpl_connect('button_press_event', on_press)
    #...later
    canvas.mpl_disconnect(cid)


raise NotImplementedError<EOL>

Flush the GUI events for the figure. Implemented only for
backends with GUIs.


raise NotImplementedError<EOL>

Start an event loop.  This is used to start a blocking event
loop so that interactive functions, such as ginput and
waitforbuttonpress, can wait for events.  This should not be
confused with the main GUI event loop, which is always running
and has nothing to do with this.

This is implemented only for backends with GUIs.


raise NotImplementedError<EOL>

Stop an event loop.  This is used to stop a blocking event
loop so that interactive functions, such as ginput and
waitforbuttonpress, can wait for events.

This is implemented only for backends with GUIs.


str = "<STR_LIT>"<EOL>str += "<STR_LIT>"<EOL>warnings.warn(str,DeprecationWarning)<EOL>if timeout <= <NUM_LIT:0>: timeout = np.inf<EOL>timestep = <NUM_LIT><EOL>counter = <NUM_LIT:0><EOL>self._looping = True<EOL>while self._looping and counter*timestep < timeout:<EOL><INDENT>self.flush_events()<EOL>time.sleep(timestep)<EOL>counter += <NUM_LIT:1><EOL><DEDENT>

Start an event loop.  This is used to start a blocking event
loop so that interactive functions, such as ginput and
waitforbuttonpress, can wait for events.  This should not be
confused with the main GUI event loop, which is always running
and has nothing to do with this.

This function provides default event loop functionality based
on time.sleep that is meant to be used until event loop
functions for each of the GUI backends can be written.  As
such, it throws a deprecated warning.

Call signature::

    start_event_loop_default(self,timeout=0)

This call blocks until a callback function triggers
stop_event_loop() or *timeout* is reached.  If *timeout* is
<=0, never timeout.


self._looping = False<EOL>

Stop an event loop.  This is used to stop a blocking event
loop so that interactive functions, such as ginput and
waitforbuttonpress, can wait for events.

Call signature::

  stop_event_loop_default(self)


pass<EOL>

For gui backends: resize window in pixels


pass<EOL>


pass<EOL>

display a message on toolbar or in status bar


self._views.back()<EOL>self._positions.back()<EOL>self.set_history_buttons()<EOL>self._update_view()<EOL>


def draw_rubberband(self, event, x0, y0, x1, y1):

pass<EOL>

draw a rectangle rubberband to indicate zoom limits


self._views.forward()<EOL>self._positions.forward()<EOL>self.set_history_buttons()<EOL>self._update_view()<EOL>


self._views.home()<EOL>self._positions.home()<EOL>self.set_history_buttons()<EOL>self._update_view()<EOL>


raise NotImplementedError<EOL>

This is where you actually build the GUI widgets (called by
__init__).  The icons ``home.xpm``, ``back.xpm``, ``forward.xpm``,
``hand.xpm``, ``zoom_to_rect.xpm`` and ``filesave.xpm`` are standard
across backends (there are ppm versions in CVS also).

You just need to set the callbacks

home         : self.home
back         : self.back
forward      : self.forward
hand         : self.pan
zoom_to_rect : self.zoom
filesave     : self.save_figure

You only need to define the last one - the others are in the base
class implementation.


<EOL>if self._active == '<STR_LIT>':<EOL><INDENT>self._active = None<EOL><DEDENT>else:<EOL><INDENT>self._active = '<STR_LIT>'<EOL><DEDENT>if self._idPress is not None:<EOL><INDENT>self._idPress = self.canvas.mpl_disconnect(self._idPress)<EOL>self.mode = '<STR_LIT>'<EOL><DEDENT>if self._idRelease is not None:<EOL><INDENT>self._idRelease = self.canvas.mpl_disconnect(self._idRelease)<EOL>self.mode = '<STR_LIT>'<EOL><DEDENT>if self._active:<EOL><INDENT>self._idPress = self.canvas.mpl_connect(<EOL>'<STR_LIT>', self.press_pan)<EOL>self._idRelease = self.canvas.mpl_connect(<EOL>'<STR_LIT>', self.release_pan)<EOL>self.mode = '<STR_LIT>'<EOL>self.canvas.widgetlock(self)<EOL><DEDENT>else:<EOL><INDENT>self.canvas.widgetlock.release(self)<EOL><DEDENT>for a in self.canvas.figure.get_axes():<EOL><INDENT>a.set_navigate_mode(self._active)<EOL><DEDENT>self.set_message(self.mode)<EOL>

Activate the pan/zoom tool. pan with left button, zoom with right


pass<EOL>

this will be called whenver a mouse button is pressed


if event.button == <NUM_LIT:1>:<EOL><INDENT>self._button_pressed=<NUM_LIT:1><EOL><DEDENT>elif  event.button == <NUM_LIT:3>:<EOL><INDENT>self._button_pressed=<NUM_LIT:3><EOL><DEDENT>else:<EOL><INDENT>self._button_pressed=None<EOL>return<EOL><DEDENT>x, y = event.x, event.y<EOL>if self._views.empty(): self.push_current()<EOL>self._xypress=[]<EOL>for i, a in enumerate(self.canvas.figure.get_axes()):<EOL><INDENT>if x is not None and y is not None and a.in_axes(event) and a.get_navigate():<EOL><INDENT>a.start_pan(x, y, event.button)<EOL>self._xypress.append((a, i))<EOL>self.canvas.mpl_disconnect(self._idDrag)<EOL>self._idDrag=self.canvas.mpl_connect('<STR_LIT>', self.drag_pan)<EOL><DEDENT><DEDENT>self.press(event)<EOL>

the press mouse button in pan/zoom mode callback


if event.button == <NUM_LIT:1>:<EOL><INDENT>self._button_pressed=<NUM_LIT:1><EOL><DEDENT>elif  event.button == <NUM_LIT:3>:<EOL><INDENT>self._button_pressed=<NUM_LIT:3><EOL><DEDENT>else:<EOL><INDENT>self._button_pressed=None<EOL>return<EOL><DEDENT>x, y = event.x, event.y<EOL>if self._views.empty(): self.push_current()<EOL>self._xypress=[]<EOL>for i, a in enumerate(self.canvas.figure.get_axes()):<EOL><INDENT>if x is not None and y is not None and a.in_axes(event)and a.get_navigate() and a.can_zoom():<EOL><INDENT>self._xypress.append(( x, y, a, i, a.viewLim.frozen(), a.transData.frozen()))<EOL><DEDENT><DEDENT>self.press(event)<EOL>

the press mouse button in zoom to rect mode callback


lims = []; pos = []<EOL>for a in self.canvas.figure.get_axes():<EOL><INDENT>xmin, xmax = a.get_xlim()<EOL>ymin, ymax = a.get_ylim()<EOL>lims.append( (xmin, xmax, ymin, ymax) )<EOL>pos.append( (<EOL>a.get_position(True).frozen(),<EOL>a.get_position().frozen() ) )<EOL><DEDENT>self._views.push(lims)<EOL>self._positions.push(pos)<EOL>self.set_history_buttons()<EOL>

push the current view limits and position onto the stack


pass<EOL>

this will be called whenever mouse button is released


self.canvas.mpl_disconnect(self._idDrag)<EOL>self._idDrag=self.canvas.mpl_connect('<STR_LIT>', self.mouse_move)<EOL>for a, ind in self._xypress:<EOL><INDENT>a.end_pan()<EOL><DEDENT>if not self._xypress: return<EOL>self._xypress = []<EOL>self._button_pressed=None<EOL>self.push_current()<EOL>self.release(event)<EOL>self.draw()<EOL>

the release mouse button callback in pan/zoom mode


for a, ind in self._xypress:<EOL><INDENT>a.drag_pan(self._button_pressed, event.key, event.x, event.y)<EOL><DEDENT>self.dynamic_update()<EOL>


if not self._xypress: return<EOL>last_a = []<EOL>for cur_xypress in self._xypress:<EOL><INDENT>x, y = event.x, event.y<EOL>lastx, lasty, a, ind, lim, trans = cur_xypress<EOL>if abs(x-lastx)<<NUM_LIT:5> or abs(y-lasty)<<NUM_LIT:5>:<EOL><INDENT>self._xypress = None<EOL>self.release(event)<EOL>self.draw()<EOL>return<EOL><DEDENT>x0, y0, x1, y1 = lim.extents<EOL>inverse = a.transData.inverted()<EOL>lastx, lasty = inverse.transform_point( (lastx, lasty) )<EOL>x, y = inverse.transform_point( (x, y) )<EOL>Xmin,Xmax=a.get_xlim()<EOL>Ymin,Ymax=a.get_ylim()<EOL>twinx, twiny = False, False<EOL>if last_a:<EOL><INDENT>for la in last_a:<EOL><INDENT>if a.get_shared_x_axes().joined(a,la): twinx=True<EOL>if a.get_shared_y_axes().joined(a,la): twiny=True<EOL><DEDENT><DEDENT>last_a.append(a)<EOL>if twinx:<EOL><INDENT>x0, x1 = Xmin, Xmax<EOL><DEDENT>else:<EOL><INDENT>if Xmin < Xmax:<EOL><INDENT>if x<lastx:  x0, x1 = x, lastx<EOL>else: x0, x1 = lastx, x<EOL>if x0 < Xmin: x0=Xmin<EOL>if x1 > Xmax: x1=Xmax<EOL><DEDENT>else:<EOL><INDENT>if x>lastx:  x0, x1 = x, lastx<EOL>else: x0, x1 = lastx, x<EOL>if x0 > Xmin: x0=Xmin<EOL>if x1 < Xmax: x1=Xmax<EOL><DEDENT><DEDENT>if twiny:<EOL><INDENT>y0, y1 = Ymin, Ymax<EOL><DEDENT>else:<EOL><INDENT>if Ymin < Ymax:<EOL><INDENT>if y<lasty:  y0, y1 = y, lasty<EOL>else: y0, y1 = lasty, y<EOL>if y0 < Ymin: y0=Ymin<EOL>if y1 > Ymax: y1=Ymax<EOL><DEDENT>else:<EOL><INDENT>if y>lasty:  y0, y1 = y, lasty<EOL>else: y0, y1 = lasty, y<EOL>if y0 > Ymin: y0=Ymin<EOL>if y1 < Ymax: y1=Ymax<EOL><DEDENT><DEDENT>if self._button_pressed == <NUM_LIT:1>:<EOL><INDENT>a.set_xlim((x0, x1))<EOL>a.set_ylim((y0, y1))<EOL><DEDENT>elif self._button_pressed == <NUM_LIT:3>:<EOL><INDENT>if a.get_xscale()=='<STR_LIT>':<EOL><INDENT>alpha=np.log(Xmax/Xmin)/np.log(x1/x0)<EOL>rx1=pow(Xmin/x0,alpha)*Xmin<EOL>rx2=pow(Xmax/x0,alpha)*Xmin<EOL><DEDENT>else:<EOL><INDENT>alpha=(Xmax-Xmin)/(x1-x0)<EOL>rx1=alpha*(Xmin-x0)+Xmin<EOL>rx2=alpha*(Xmax-x0)+Xmin<EOL><DEDENT>if a.get_yscale()=='<STR_LIT>':<EOL><INDENT>alpha=np.log(Ymax/Ymin)/np.log(y1/y0)<EOL>ry1=pow(Ymin/y0,alpha)*Ymin<EOL>ry2=pow(Ymax/y0,alpha)*Ymin<EOL><DEDENT>else:<EOL><INDENT>alpha=(Ymax-Ymin)/(y1-y0)<EOL>ry1=alpha*(Ymin-y0)+Ymin<EOL>ry2=alpha*(Ymax-y0)+Ymin<EOL><DEDENT>a.set_xlim((rx1, rx2))<EOL>a.set_ylim((ry1, ry2))<EOL><DEDENT><DEDENT>self.draw()<EOL>self._xypress = None<EOL>self._button_pressed = None<EOL>self.push_current()<EOL>self.release(event)<EOL>

the release mouse button callback in zoom to rect mode


for a in self.canvas.figure.get_axes():<EOL><INDENT>xaxis = getattr(a, '<STR_LIT>', None)<EOL>yaxis = getattr(a, '<STR_LIT>', None)<EOL>locators = []<EOL>if xaxis is not None:<EOL><INDENT>locators.append(xaxis.get_major_locator())<EOL>locators.append(xaxis.get_minor_locator())<EOL><DEDENT>if yaxis is not None:<EOL><INDENT>locators.append(yaxis.get_major_locator())<EOL>locators.append(yaxis.get_minor_locator())<EOL><DEDENT>for loc in locators:<EOL><INDENT>loc.refresh()<EOL><DEDENT><DEDENT>self.canvas.draw()<EOL>

redraw the canvases, update the locators


lims = self._views()<EOL>if lims is None:  return<EOL>pos = self._positions()<EOL>if pos is None: return<EOL>for i, a in enumerate(self.canvas.figure.get_axes()):<EOL><INDENT>xmin, xmax, ymin, ymax = lims[i]<EOL>a.set_xlim((xmin, xmax))<EOL>a.set_ylim((ymin, ymax))<EOL>a.set_position( pos[i][<NUM_LIT:0>], '<STR_LIT>' )<EOL>a.set_position( pos[i][<NUM_LIT:1>], '<STR_LIT>' )<EOL><DEDENT>self.draw()<EOL>

update the viewlim and position from the view and
        position stack for each axes


raise NotImplementedError<EOL>


pass<EOL>

Set the current cursor to one of the :class:`Cursors`
enums values


self._views.clear()<EOL>self._positions.clear()<EOL>self.set_history_buttons()<EOL>


if self._active == '<STR_LIT>':<EOL><INDENT>self._active = None<EOL><DEDENT>else:<EOL><INDENT>self._active = '<STR_LIT>'<EOL><DEDENT>if self._idPress is not None:<EOL><INDENT>self._idPress=self.canvas.mpl_disconnect(self._idPress)<EOL>self.mode = '<STR_LIT>'<EOL><DEDENT>if self._idRelease is not None:<EOL><INDENT>self._idRelease=self.canvas.mpl_disconnect(self._idRelease)<EOL>self.mode = '<STR_LIT>'<EOL><DEDENT>if  self._active:<EOL><INDENT>self._idPress = self.canvas.mpl_connect('<STR_LIT>', self.press_zoom)<EOL>self._idRelease = self.canvas.mpl_connect('<STR_LIT>', self.release_zoom)<EOL>self.mode = '<STR_LIT>'<EOL>self.canvas.widgetlock(self)<EOL><DEDENT>else:<EOL><INDENT>self.canvas.widgetlock.release(self)<EOL><DEDENT>for a in self.canvas.figure.get_axes():<EOL><INDENT>a.set_navigate_mode(self._active)<EOL><DEDENT>self.set_message(self.mode)<EOL>


pass<EOL>


assert <NUM_LIT:0> <= num < <NUM_LIT:2>**<NUM_LIT:32><EOL>if num & <NUM_LIT:2>**<NUM_LIT>:<EOL><INDENT>return num - <NUM_LIT:2>**<NUM_LIT:32><EOL><DEDENT>else:<EOL><INDENT>return num<EOL><DEDENT>

Convert from two's complement to negative.


<EOL>return (num1*num2) >> <NUM_LIT:20><EOL>

Multiply two numbers in 20.12 fixed point format.


cmd = ['<STR_LIT>']<EOL>if format is not None:<EOL><INDENT>cmd += ['<STR_LIT>' + format]<EOL><DEDENT>cmd += [filename]<EOL>matplotlib.verbose.report('<STR_LIT>'% (filename,cmd), '<STR_LIT>')<EOL>pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)<EOL>result = pipe.communicate()[<NUM_LIT:0>].rstrip()<EOL>matplotlib.verbose.report('<STR_LIT>' % result,<EOL>'<STR_LIT>')<EOL>return result<EOL>

Call kpsewhich to find a file in the texmf tree.
If format is not None, it is used as the value for the --format option.
See the kpathsea documentation for more information.

Apparently most existing TeX distributions on Unix-like systems
use kpathsea. I hear MikTeX (a popular distribution on Windows)
doesn't use kpathsea, so what do we do? (TODO)


matplotlib.verbose.report('<STR_LIT>' + filename, '<STR_LIT>')<EOL>self.file = open(filename, '<STR_LIT:rb>')<EOL>self.dpi = dpi<EOL>self.fonts = {}<EOL>self.state = _dvistate.pre<EOL>

Initialize the object. This takes the filename as input and
opens the file; actually reading the file happens when
iterating through the pages of the file.


while True:<EOL><INDENT>have_page = self._read()<EOL>if have_page:<EOL><INDENT>yield self._output()<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>

Iterate through the pages of the file.

Returns (text, pages) pairs, where:
  text is a list of (x, y, fontnum, glyphnum, width) tuples
  boxes is a list of (x, y, height, width) tuples

The coordinates are transformed into a standard Cartesian
coordinate system at the dpi value given when initializing.
The coordinates are floating point numbers, but otherwise
precision is not lost and coordinate values are not clipped to
integers.


if not self.file.closed:<EOL><INDENT>self.file.close()<EOL><DEDENT>

Close the underlying file if it is open.


minx, miny, maxx, maxy = np.inf, np.inf, -np.inf, -np.inf<EOL>maxy_pure = -np.inf<EOL>for elt in self.text + self.boxes:<EOL><INDENT>if len(elt) == <NUM_LIT:4>:   <EOL><INDENT>x,y,h,w = elt<EOL>e = <NUM_LIT:0>           <EOL><DEDENT>else:               <EOL><INDENT>x,y,font,g,w = elt<EOL>h = _mul2012(font._scale, font._tfm.height[g])<EOL>e = _mul2012(font._scale, font._tfm.depth[g])<EOL><DEDENT>minx = min(minx, x)<EOL>miny = min(miny, y - h)<EOL>maxx = max(maxx, x + w)<EOL>maxy = max(maxy, y + e)<EOL>maxy_pure = max(maxy_pure, y)<EOL><DEDENT>if self.dpi is None:<EOL><INDENT>return mpl_cbook.Bunch(text=self.text, boxes=self.boxes,<EOL>width=maxx-minx, height=maxy_pure-miny,<EOL>descent=maxy-maxy_pure)<EOL><DEDENT>d = self.dpi / (<NUM_LIT> * <NUM_LIT:2>**<NUM_LIT:16>) <EOL>text =  [ ((x-minx)*d, (maxy-y)*d, f, g, w*d)<EOL>for (x,y,f,g,w) in self.text ]<EOL>boxes = [ ((x-minx)*d, (maxy-y)*d, h*d, w*d) for (x,y,h,w) in self.boxes ]<EOL>return mpl_cbook.Bunch(text=text, boxes=boxes,<EOL>width=(maxx-minx)*d,<EOL>height=(maxy_pure-miny)*d,<EOL>descent=(maxy-maxy_pure)*d)<EOL>

Output the text and boxes belonging to the most recent page.
page = dvi._output()


while True:<EOL><INDENT>byte = ord(self.file.read(<NUM_LIT:1>))<EOL>self._dispatch(byte)<EOL><INDENT>if self.state == _dvistate.inpage:<EOL><INDENT>matplotlib.verbose.report(<EOL>'<STR_LIT>' %<EOL>(byte, self.h, self.v),<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>if byte == <NUM_LIT>: <EOL><INDENT>return True<EOL><DEDENT>if self.state == _dvistate.post_post: <EOL><INDENT>self.close()<EOL>return False<EOL><DEDENT><DEDENT>

Read one page from the file. Return True if successful,
False if there were no more pages.


str = self.file.read(nbytes)<EOL>value = ord(str[<NUM_LIT:0>])<EOL>if signed and value >= <NUM_LIT>:<EOL><INDENT>value = value - <NUM_LIT><EOL><DEDENT>for i in range(<NUM_LIT:1>, nbytes):<EOL><INDENT>value = <NUM_LIT>*value + ord(str[i])<EOL><DEDENT>return value<EOL>

Read and return an integer argument "nbytes" long.
Signedness is determined by the "signed" keyword.


if <NUM_LIT:0> <= byte <= <NUM_LIT>: self._set_char(byte)<EOL>elif byte == <NUM_LIT>: self._set_char(self._arg(<NUM_LIT:1>))<EOL>elif byte == <NUM_LIT>: self._set_char(self._arg(<NUM_LIT:2>))<EOL>elif byte == <NUM_LIT>: self._set_char(self._arg(<NUM_LIT:3>))<EOL>elif byte == <NUM_LIT>: self._set_char(self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._set_rule(self._arg(<NUM_LIT:4>, True), self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._put_char(self._arg(<NUM_LIT:1>))<EOL>elif byte == <NUM_LIT>: self._put_char(self._arg(<NUM_LIT:2>))<EOL>elif byte == <NUM_LIT>: self._put_char(self._arg(<NUM_LIT:3>))<EOL>elif byte == <NUM_LIT>: self._put_char(self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._put_rule(self._arg(<NUM_LIT:4>, True), self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._nop()<EOL>elif byte == <NUM_LIT>: self._bop(*[self._arg(<NUM_LIT:4>, True) for i in range(<NUM_LIT:11>)])<EOL>elif byte == <NUM_LIT>: self._eop()<EOL>elif byte == <NUM_LIT>: self._push()<EOL>elif byte == <NUM_LIT>: self._pop()<EOL>elif byte == <NUM_LIT>: self._right(self._arg(<NUM_LIT:1>, True))<EOL>elif byte == <NUM_LIT>: self._right(self._arg(<NUM_LIT:2>, True))<EOL>elif byte == <NUM_LIT>: self._right(self._arg(<NUM_LIT:3>, True))<EOL>elif byte == <NUM_LIT>: self._right(self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._right_w(None)<EOL>elif byte == <NUM_LIT>: self._right_w(self._arg(<NUM_LIT:1>, True))<EOL>elif byte == <NUM_LIT>: self._right_w(self._arg(<NUM_LIT:2>, True))<EOL>elif byte == <NUM_LIT>: self._right_w(self._arg(<NUM_LIT:3>, True))<EOL>elif byte == <NUM_LIT>: self._right_w(self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._right_x(None)<EOL>elif byte == <NUM_LIT>: self._right_x(self._arg(<NUM_LIT:1>, True))<EOL>elif byte == <NUM_LIT>: self._right_x(self._arg(<NUM_LIT:2>, True))<EOL>elif byte == <NUM_LIT>: self._right_x(self._arg(<NUM_LIT:3>, True))<EOL>elif byte == <NUM_LIT>: self._right_x(self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._down(self._arg(<NUM_LIT:1>, True))<EOL>elif byte == <NUM_LIT>: self._down(self._arg(<NUM_LIT:2>, True))<EOL>elif byte == <NUM_LIT>: self._down(self._arg(<NUM_LIT:3>, True))<EOL>elif byte == <NUM_LIT>: self._down(self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._down_y(None)<EOL>elif byte == <NUM_LIT>: self._down_y(self._arg(<NUM_LIT:1>, True))<EOL>elif byte == <NUM_LIT>: self._down_y(self._arg(<NUM_LIT:2>, True))<EOL>elif byte == <NUM_LIT>: self._down_y(self._arg(<NUM_LIT:3>, True))<EOL>elif byte == <NUM_LIT>: self._down_y(self._arg(<NUM_LIT:4>, True))<EOL>elif byte == <NUM_LIT>: self._down_z(None)<EOL>elif byte == <NUM_LIT>: self._down_z(self._arg(<NUM_LIT:1>, True))<EOL>elif byte == <NUM_LIT>: self._down_z(self._arg(<NUM_LIT:2>, True))<EOL>elif byte == <NUM_LIT>: self._down_z(self._arg(<NUM_LIT:3>, True))<EOL>elif byte == <NUM_LIT>: self._down_z(self._arg(<NUM_LIT:4>, True))<EOL>elif <NUM_LIT> <= byte <= <NUM_LIT>: self._fnt_num(byte-<NUM_LIT>)<EOL>elif byte == <NUM_LIT>: self._fnt_num(self._arg(<NUM_LIT:1>))<EOL>elif byte == <NUM_LIT>: self._fnt_num(self._arg(<NUM_LIT:2>))<EOL>elif byte == <NUM_LIT>: self._fnt_num(self._arg(<NUM_LIT:3>))<EOL>elif byte == <NUM_LIT>: self._fnt_num(self._arg(<NUM_LIT:4>, True))<EOL>elif <NUM_LIT> <= byte <= <NUM_LIT>:<EOL><INDENT>len = self._arg(byte-<NUM_LIT>)<EOL>special = self.file.read(len)<EOL>self._xxx(special)<EOL><DEDENT>elif <NUM_LIT> <= byte <= <NUM_LIT>:<EOL><INDENT>k = self._arg(byte-<NUM_LIT>, byte==<NUM_LIT>)<EOL>c, s, d, a, l = [ self._arg(x) for x in (<NUM_LIT:4>, <NUM_LIT:4>, <NUM_LIT:4>, <NUM_LIT:1>, <NUM_LIT:1>) ]<EOL>n = self.file.read(a+l)<EOL>self._fnt_def(k, c, s, d, a, l, n)<EOL><DEDENT>elif byte == <NUM_LIT>:<EOL><INDENT>i, num, den, mag, k = [ self._arg(x) for x in (<NUM_LIT:1>, <NUM_LIT:4>, <NUM_LIT:4>, <NUM_LIT:4>, <NUM_LIT:1>) ]<EOL>x = self.file.read(k)<EOL>self._pre(i, num, den, mag, x)<EOL><DEDENT>elif byte == <NUM_LIT>: self._post()<EOL>elif byte == <NUM_LIT>: self._post_post()<EOL>else:<EOL><INDENT>raise ValueError("<STR_LIT>"%byte)<EOL><DEDENT>

Based on the opcode "byte", read the correct kinds of
arguments from the dvi file and call the method implementing
that opcode with those arguments.


width = self._tfm.width.get(char, None)<EOL>if width is not None:<EOL><INDENT>return _mul2012(width, self._scale)<EOL><DEDENT>matplotlib.verbose.report(<EOL>'<STR_LIT>' % (char, self.texname),<EOL>'<STR_LIT>')<EOL>return <NUM_LIT:0><EOL>

Width of char in dvi units. For internal use by dviread.py.


for line in file:<EOL><INDENT>line = line.strip()<EOL>if line == '<STR_LIT>' or line.startswith('<STR_LIT:%>'):<EOL><INDENT>continue<EOL><DEDENT>words, pos = [], <NUM_LIT:0><EOL>while pos < len(line):<EOL><INDENT>if line[pos] == '<STR_LIT:">': <EOL><INDENT>pos += <NUM_LIT:1><EOL>end = line.index('<STR_LIT:">', pos)<EOL>words.append(line[pos:end])<EOL>pos = end + <NUM_LIT:1><EOL><DEDENT>else:                <EOL><INDENT>end = line.find('<STR_LIT:U+0020>', pos+<NUM_LIT:1>)<EOL>if end == -<NUM_LIT:1>: end = len(line)<EOL>words.append(line[pos:end])<EOL>pos = end<EOL><DEDENT>while pos < len(line) and line[pos] == '<STR_LIT:U+0020>':<EOL><INDENT>pos += <NUM_LIT:1><EOL><DEDENT><DEDENT>self._register(words)<EOL><DEDENT>


texname, psname = words[:<NUM_LIT:2>]<EOL>effects, encoding, filename = [], None, None<EOL>for word in words[<NUM_LIT:2>:]:<EOL><INDENT>if not word.startswith('<STR_LIT:<>'):<EOL><INDENT>effects.append(word)<EOL><DEDENT>else:<EOL><INDENT>word = word.lstrip('<STR_LIT:<>')<EOL>if word.startswith('<STR_LIT:[>'):<EOL><INDENT>assert encoding is None<EOL>encoding = word[<NUM_LIT:1>:]<EOL><DEDENT>elif word.endswith('<STR_LIT>'):<EOL><INDENT>assert encoding is None<EOL>encoding = word<EOL><DEDENT>else:<EOL><INDENT>assert filename is None<EOL>filename = word<EOL><DEDENT><DEDENT><DEDENT>self._font[texname] = mpl_cbook.Bunch(<EOL>texname=texname, psname=psname, effects=effects,<EOL>encoding=encoding, filename=filename)<EOL>

Register a font described by "words".

        The format is, AFAIK: texname fontname [effects and filenames]
        Effects are PostScript snippets like ".177 SlantFont",
        filenames begin with one or two less-than signs. A filename
        ending in enc is an encoding file, other filenames are font
        files. This can be overridden with a left bracket: <[foobar
        indicates an encoding file named foobar.

        There is some difference between <foo.pfb and <<bar.pfb in
        subsetting, but I have no example of << in my TeX installation.


remove = (r'<STR_LIT>', r'<STR_LIT>', r'<STR_LIT>', r'<STR_LIT>', r'<STR_LIT>', '<STR_LIT:\\>', '<STR_LIT:{>', '<STR_LIT:}>')<EOL>s = s[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL>for r in remove:  s = s.replace(r,'<STR_LIT>')<EOL>return s<EOL>


return list(dict([ (val, <NUM_LIT:1>) for val in x]).keys())<EOL>


try: len(obj)<EOL>except: return False<EOL>return True<EOL>


if isinstance(obj, str): return True<EOL>if ma.isMaskedArray(obj):<EOL><INDENT>if obj.ndim == <NUM_LIT:0> and obj.dtype.kind in '<STR_LIT>':<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>try: obj + '<STR_LIT>'<EOL>except (TypeError, ValueError): return False<EOL>return True<EOL>

Return True if *obj* looks like a string


if not iterable(obj): return False<EOL>if is_string_like(obj): return False<EOL>for o in obj:<EOL><INDENT>if not is_string_like(o): return False<EOL><DEDENT>return True<EOL>

Returns true if *obj* is iterable and contains strings


return hasattr(obj, '<STR_LIT>') and callable(obj.write)<EOL>

return true if *obj* looks like a file object with a *write* method


return not is_string_like(obj) and not iterable(obj)<EOL>

return true if *obj* is not string like and is not iterable


try: obj+<NUM_LIT:1><EOL>except TypeError: return False<EOL>else: return True<EOL>

return true if *obj* looks like a number


def to_filehandle(fname, flag='<STR_LIT:r>', return_opened=False):

if is_string_like(fname):<EOL><INDENT>if fname.endswith('<STR_LIT>'):<EOL><INDENT>import gzip<EOL>fh = gzip.open(fname, flag)<EOL><DEDENT>else:<EOL><INDENT>fh = file(fname, flag)<EOL><DEDENT>opened = True<EOL><DEDENT>elif hasattr(fname, '<STR_LIT>'):<EOL><INDENT>fh = fname<EOL>opened = False<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if return_opened:<EOL><INDENT>return fh, opened<EOL><DEDENT>return fh<EOL>

*fname* can be a filename or a file handle.  Support for gzipped
files is automatic, if the filename ends in .gz.  *flag* is a
read/write flag for :func:`file`


for item in seq:<EOL><INDENT>if scalarp(item): yield item<EOL>else:<EOL><INDENT>for subitem in flatten(item, scalarp):<EOL><INDENT>yield subitem<EOL><DEDENT><DEDENT><DEDENT>

this generator flattens nested containers such as

>>> l=( ('John', 'Hunter'), (1,23), [[[[42,(5,23)]]]])

so that

>>> for i in flatten(l): print i,
John Hunter 1 23 42 5 23

By: Composite of Holger Krekel and Luther Blissett
From: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294
and Recipe 1.12 in cookbook


<EOL>soundex_digits = '<STR_LIT>'<EOL>sndx = '<STR_LIT>'<EOL>fc = '<STR_LIT>'<EOL>for c in name.upper():<EOL><INDENT>if c.isalpha():<EOL><INDENT>if not fc: fc = c   <EOL>d = soundex_digits[ord(c)-ord('<STR_LIT:A>')]<EOL>if not sndx or (d != sndx[-<NUM_LIT:1>]):<EOL><INDENT>sndx += d<EOL><DEDENT><DEDENT><DEDENT>sndx = fc + sndx[<NUM_LIT:1>:]<EOL>sndx = sndx.replace('<STR_LIT:0>', '<STR_LIT>')<EOL>return (sndx + (len * '<STR_LIT:0>'))[:len]<EOL>

soundex module conforming to Odell-Russell algorithm


try:<EOL><INDENT>if not os.path.exists(newdir):<EOL><INDENT>parts = os.path.split(newdir)<EOL>for i in range(<NUM_LIT:1>, len(parts)+<NUM_LIT:1>):<EOL><INDENT>thispart = os.path.join(*parts[:i])<EOL>if not os.path.exists(thispart):<EOL><INDENT>os.makedirs(thispart, mode)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except OSError as err:<EOL><INDENT>if err.errno != errno.EEXIST or not os.path.isdir(newdir):<EOL><INDENT>raise<EOL><DEDENT><DEDENT>

make directory *newdir* recursively, and set *mode*.  Equivalent to ::

    > mkdir -p NEWDIR
    > chmod MODE NEWDIR


for key in keys:<EOL><INDENT>try: del d[key]<EOL>except KeyError: pass<EOL><DEDENT>

delete all of the *keys* from the :class:`dict` *d*


sLen = <NUM_LIT:0><EOL>for (word, ind) in zip(seq, list(range(len(seq)))):<EOL><INDENT>sLen += len(word) + <NUM_LIT:1>  <EOL>if sLen>=N: return ind<EOL><DEDENT>return len(seq)<EOL>

*seq* is a list of words.  Return the index into seq such that::

    len(' '.join(seq[:ind])<=N


pad = '<STR_LIT:U+0020>'*len(prefix.expandtabs())<EOL>available = cols - len(pad)<EOL>seq = text.split('<STR_LIT:U+0020>')<EOL>Nseq = len(seq)<EOL>ind = <NUM_LIT:0><EOL>lines = []<EOL>while ind<Nseq:<EOL><INDENT>lastInd = ind<EOL>ind += get_split_ind(seq[ind:], available)<EOL>lines.append(seq[lastInd:ind])<EOL><DEDENT>ret = prefix + '<STR_LIT:U+0020>'.join(lines[<NUM_LIT:0>]) + '<STR_LIT:\n>'<EOL>for line in lines[<NUM_LIT:1>:]:<EOL><INDENT>ret += pad + '<STR_LIT:U+0020>'.join(line) + '<STR_LIT:\n>'<EOL><DEDENT>return ret<EOL>

wrap *text* with *prefix* at length *cols*


<EOL>if not s:      <EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>match = _find_dedent_regex.match(s)<EOL>if match is None:<EOL><INDENT>return s<EOL><DEDENT>nshift = match.end(<NUM_LIT:1>) - match.start(<NUM_LIT:1>)<EOL>if nshift == <NUM_LIT:0>:<EOL><INDENT>return s<EOL><DEDENT>unindent = _dedent_regex.get(nshift, None)<EOL>if unindent is None:<EOL><INDENT>unindent = re.compile("<STR_LIT>" % nshift)<EOL>_dedent_regex[nshift] = unindent<EOL><DEDENT>result = unindent.sub("<STR_LIT:\n>", s).strip()<EOL>return result<EOL>

Remove excess indentation from docstring *s*.

Discards any leading blank lines, then removes up to n whitespace
characters from each line, where n is the number of leading
whitespace characters in the first line. It differs from
textwrap.dedent in its deletion of leading blank lines and its use
of the first non-blank line to determine the indentation.

It is also faster in most cases.


def listFiles(root, patterns='<STR_LIT:*>', recurse=<NUM_LIT:1>, return_folders=<NUM_LIT:0>):

import os.path, fnmatch<EOL>pattern_list = patterns.split('<STR_LIT:;>')<EOL>class Bunch:<EOL><INDENT>def __init__(self, **kwds): self.__dict__.update(kwds)<EOL><DEDENT>arg = Bunch(recurse=recurse, pattern_list=pattern_list,<EOL>return_folders=return_folders, results=[])<EOL>def visit(arg, dirname, files):<EOL><INDENT>for name in files:<EOL><INDENT>fullname = os.path.normpath(os.path.join(dirname, name))<EOL>if arg.return_folders or os.path.isfile(fullname):<EOL><INDENT>for pattern in arg.pattern_list:<EOL><INDENT>if fnmatch.fnmatch(name, pattern):<EOL><INDENT>arg.results.append(fullname)<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if not arg.recurse: files[:]=[]<EOL><DEDENT>os.path.walk(root, visit, arg)<EOL>return arg.results<EOL>

Recursively list files

from Parmar and Martelli in the Python Cookbook


files = []<EOL>for arg in args:<EOL><INDENT>if os.path.isfile(arg):<EOL><INDENT>files.append(arg)<EOL>continue<EOL><DEDENT>if os.path.isdir(arg):<EOL><INDENT>newfiles = listFiles(arg, recurse=<NUM_LIT:1>, return_folders=<NUM_LIT:1>)<EOL>files.extend(newfiles)<EOL><DEDENT><DEDENT>return [f for f in files if not os.path.islink(f)]<EOL>

Recurs all the files and dirs in *args* ignoring symbolic links
and return the files as a list of strings


start = <NUM_LIT:0><EOL>while <NUM_LIT:1>:<EOL><INDENT>item = seq[start:start+num]<EOL>if not len(item): break<EOL>yield item<EOL>start += num<EOL><DEDENT>


if len(seq)<<NUM_LIT:2>: return True<EOL>val = seq[<NUM_LIT:0>]<EOL>for i in range(<NUM_LIT:1>, len(seq)):<EOL><INDENT>thisval = seq[i]<EOL>if thisval != val: return False<EOL><DEDENT>return True<EOL>

Return *True* if all elements of *seq* compare equal.  If *seq* is
0 or 1 length, return *True*


if not len(seq): return False<EOL>for val in seq:<EOL><INDENT>if not val: return False<EOL><DEDENT>return True<EOL>

Return *True* if all elements of *seq* evaluate to *True*.  If
*seq* is empty, return *False*.


if not len(seq): return False<EOL>for val in seq:<EOL><INDENT>if val: return True<EOL><DEDENT>return False<EOL>

Return *True* if one element of *seq* is *True*.  It *seq* is
empty, return *False*.


return [ (s, f) for i, f in enumerate(x) for s in x[i+<NUM_LIT:1>:] ]<EOL>

return all possible pairs in sequence *x*

Condensed by Alex Martelli from this thread_ on c.l.python

.. _thread: http://groups.google.com/groups?q=all+pairs+group:*python*&hl=en&lr=&ie=UTF-8&selm=mailman.4028.1096403649.5135.python-list%40python.org&rnum=1


warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>if len(args)==<NUM_LIT:1>:<EOL><INDENT>key = args[<NUM_LIT:0>]<EOL>val = d[key]<EOL>del d[key]<EOL><DEDENT>elif len(args)==<NUM_LIT:2>:<EOL><INDENT>key, default = args<EOL>val = d.get(key, default)<EOL>try: del d[key]<EOL>except KeyError: pass<EOL><DEDENT>return val<EOL>

Should behave like python2.3 :meth:`dict.pop` method; *d* is a
:class:`dict`::

  # returns value for key and deletes item; raises a KeyError if key
  # is not in dict
  val = popd(d, key)

  # returns value for key if key exists, else default.  Delete key,
  # val item if it exists.  Will not raise a KeyError
  val = popd(d, key, default)


for i in range(len(seq)): seq.pop()<EOL>


if case:<EOL><INDENT>names = [(name,name) for name in dir(o) if is_string_like(name)]<EOL><DEDENT>else:<EOL><INDENT>names = [(name.lower(), name) for name in dir(o) if is_string_like(name)]<EOL>match = match.lower()<EOL><DEDENT>return [orig for name, orig in names if name.find(match)>=<NUM_LIT:0>]<EOL>

return all attributes of *o* which match string in match.  if case
is True require an exact case match.


return dict([(v,k) for k,v in list(d.items())])<EOL>

reverse the dictionary -- may lose data if values are not unique!


pid = os.getpid()<EOL>if sys.platform=='<STR_LIT>':<EOL><INDENT>a2 = os.popen('<STR_LIT>' % pid).readlines()<EOL>mem = int(a2[-<NUM_LIT:1>].strip())<EOL><DEDENT>elif sys.platform.startswith('<STR_LIT>'):<EOL><INDENT>a2 = os.popen('<STR_LIT>' % pid).readlines()<EOL>mem = int(a2[<NUM_LIT:1>].split()[<NUM_LIT:1>])<EOL><DEDENT>elif sys.platform.startswith('<STR_LIT>'):<EOL><INDENT>a2 = os.popen('<STR_LIT>' % pid).readlines()<EOL>mem = int(a2[<NUM_LIT:1>].split()[<NUM_LIT:0>])<EOL><DEDENT>return mem<EOL>


Nx = len(args[<NUM_LIT:0>])<EOL>for i, arg in enumerate(args[<NUM_LIT:1>:]):<EOL><INDENT>if len(arg) != Nx:<EOL><INDENT>raise ValueError(_safezip_msg % (Nx, i+<NUM_LIT:1>, len(arg)))<EOL><DEDENT><DEDENT>return list(zip(*args))<EOL>

make sure *args* are equal len before zipping


try:<EOL><INDENT>return issubclass(x, klass)<EOL><DEDENT>except TypeError:<EOL><INDENT>return False<EOL><DEDENT>

return issubclass(x, klass) and return False on a TypeError


def print_cycles(objects, outstream=sys.stdout, show_progress=False):

import gc<EOL>from types import FrameType<EOL>def print_path(path):<EOL><INDENT>for i, step in enumerate(path):<EOL><INDENT>next = path[(i + <NUM_LIT:1>) % len(path)]<EOL>outstream.write("<STR_LIT>" % str(type(step)))<EOL>if isinstance(step, dict):<EOL><INDENT>for key, val in list(step.items()):<EOL><INDENT>if val is next:<EOL><INDENT>outstream.write("<STR_LIT>" % repr(key))<EOL>break<EOL><DEDENT>if key is next:<EOL><INDENT>outstream.write("<STR_LIT>" % repr(val))<EOL>break<EOL><DEDENT><DEDENT><DEDENT>elif isinstance(step, list):<EOL><INDENT>outstream.write("<STR_LIT>" % step.index(next))<EOL><DEDENT>elif isinstance(step, tuple):<EOL><INDENT>outstream.write("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>outstream.write(repr(step))<EOL><DEDENT>outstream.write("<STR_LIT>")<EOL><DEDENT>outstream.write("<STR_LIT:\n>")<EOL><DEDENT>def recurse(obj, start, all, current_path):<EOL><INDENT>if show_progress:<EOL><INDENT>outstream.write("<STR_LIT>" % len(all))<EOL><DEDENT>all[id(obj)] = None<EOL>referents = gc.get_referents(obj)<EOL>for referent in referents:<EOL><INDENT>if referent is start:<EOL><INDENT>print_path(current_path)<EOL><DEDENT>elif referent is objects or isinstance(referent, FrameType):<EOL><INDENT>continue<EOL><DEDENT>elif id(referent) not in all:<EOL><INDENT>recurse(referent, start, all, current_path + [obj])<EOL><DEDENT><DEDENT><DEDENT>for obj in objects:<EOL><INDENT>outstream.write("<STR_LIT>" % (obj,))<EOL>recurse(obj, obj, { }, [])<EOL><DEDENT>

*objects*
    A list of objects to find cycles in.  It is often useful to
    pass in gc.garbage to find the cycles that are preventing some
    objects from being garbage collected.

*outstream*
    The stream for output.

*show_progress*
    If True, print the number of objects reached as they are found.


if not len(args):<EOL><INDENT>return ()<EOL><DEDENT>if (is_string_like(args[<NUM_LIT:0>]) or not iterable(args[<NUM_LIT:0>])):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>nrecs = len(args[<NUM_LIT:0>])<EOL>margs = []<EOL>seqlist = [False] * len(args)<EOL>for i, x in enumerate(args):<EOL><INDENT>if (not is_string_like(x)) and iterable(x) and len(x) == nrecs:<EOL><INDENT>seqlist[i] = True<EOL>if ma.isMA(x):<EOL><INDENT>if x.ndim > <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>x = np.asarray(x)<EOL><DEDENT><DEDENT>margs.append(x)<EOL><DEDENT>masks = []    <EOL>for i, x in enumerate(margs):<EOL><INDENT>if seqlist[i]:<EOL><INDENT>if x.ndim > <NUM_LIT:1>:<EOL><INDENT>continue  <EOL><DEDENT>if ma.isMA(x):<EOL><INDENT>masks.append(~ma.getmaskarray(x))  <EOL>xd = x.data<EOL><DEDENT>else:<EOL><INDENT>xd = x<EOL><DEDENT>try:<EOL><INDENT>mask = np.isfinite(xd)<EOL>if isinstance(mask, np.ndarray):<EOL><INDENT>masks.append(mask)<EOL><DEDENT><DEDENT>except: <EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>if len(masks):<EOL><INDENT>mask = reduce(np.logical_and, masks)<EOL>igood = mask.nonzero()[<NUM_LIT:0>]<EOL>if len(igood) < nrecs:<EOL><INDENT>for i, x in enumerate(margs):<EOL><INDENT>if seqlist[i]:<EOL><INDENT>margs[i] = x.take(igood, axis=<NUM_LIT:0>)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for i, x in enumerate(margs):<EOL><INDENT>if seqlist[i] and ma.isMA(x):<EOL><INDENT>margs[i] = x.filled()<EOL><DEDENT><DEDENT>return margs<EOL>

Find all masked and/or non-finite points in a set of arguments,
and return the arguments with only the unmasked points remaining.

Arguments can be in any of 5 categories:

1) 1-D masked arrays
2) 1-D ndarrays
3) ndarrays with more than one dimension
4) other non-string iterables
5) anything else

The first argument must be in one of the first four categories;
any argument with a length differing from that of the first
argument (and hence anything in category 5) then will be
passed through unchanged.

Masks are obtained from all arguments of the correct length
in categories 1, 2, and 4; a point is bad if masked in a masked
array or if it is a nan or inf.  No attempt is made to
extract a mask from categories 2, 3, and 4 if :meth:`np.isfinite`
does not yield a Boolean array.

All input arguments that are not passed unchanged are returned
as ndarrays after removing the points or rows corresponding to
masks in any of the arguments.

A vastly simpler version of this function was originally
written as a helper for Axes.scatter().


def unmasked_index_ranges(mask, compressed = True):

mask = mask.reshape(mask.size)<EOL>m = np.concatenate(((<NUM_LIT:1>,), mask, (<NUM_LIT:1>,)))<EOL>indices = np.arange(len(mask) + <NUM_LIT:1>)<EOL>mdif = m[<NUM_LIT:1>:] - m[:-<NUM_LIT:1>]<EOL>i0 = np.compress(mdif == -<NUM_LIT:1>, indices)<EOL>i1 = np.compress(mdif == <NUM_LIT:1>, indices)<EOL>assert len(i0) == len(i1)<EOL>if len(i1) == <NUM_LIT:0>:<EOL><INDENT>return None  <EOL><DEDENT>if not compressed:<EOL><INDENT>return np.concatenate((i0[:, np.newaxis], i1[:, np.newaxis]), axis=<NUM_LIT:1>)<EOL><DEDENT>seglengths = i1 - i0<EOL>breakpoints = np.cumsum(seglengths)<EOL>ic0 = np.concatenate(((<NUM_LIT:0>,), breakpoints[:-<NUM_LIT:1>]))<EOL>ic1 = breakpoints<EOL>return np.concatenate((ic0[:, np.newaxis], ic1[:, np.newaxis]), axis=<NUM_LIT:1>)<EOL>

Find index ranges where *mask* is *False*.

*mask* will be flattened if it is not already 1-D.

Returns Nx2 :class:`numpy.ndarray` with each row the start and stop
indices for slices of the compressed :class:`numpy.ndarray`
corresponding to each of *N* uninterrupted runs of unmasked
values.  If optional argument *compressed* is *False*, it returns
the start and stop indices into the original :class:`numpy.ndarray`,
not the compressed :class:`numpy.ndarray`.  Returns *None* if there
are no unmasked values.

Example::

  y = ma.array(np.arange(5), mask = [0,0,1,0,0])
  ii = unmasked_index_ranges(ma.getmaskarray(y))
  # returns array [[0,2,] [2,4,]]

  y.compressed()[ii[1,0]:ii[1,1]]
  # returns array [3,4,]

  ii = unmasked_index_ranges(ma.getmaskarray(y), compressed=False)
  # returns array [[0, 2], [3, 5]]

  y.filled()[ii[1,0]:ii[1,1]]
  # returns array [3,4,]

Prior to the transforms refactoring, this was used to support
masked arrays in Line2D.


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

<EOL>warnings.warn('<STR_LIT>', DeprecationWarning)<EOL>import matplotlib.mlab as mlab<EOL>return mlab.less_simple_linear_interpolation( x, y, xi, extrap=extrap )<EOL>

This function has been moved to matplotlib.mlab -- please import
it from there


<EOL>warnings.warn('<STR_LIT>', DeprecationWarning)<EOL>import matplotlib.mlab as mlab<EOL>return mlab.isvector( x, y, xi, extrap=extrap )<EOL>