'Draw contour lines or filled regions, depending on
whether keyword arg \'filled\' is *False* (default) or *True*.
The first three arguments must be:
*ax*: axes object.
*levels*: [level0, level1, ..., leveln]
A list of floating point numbers indicating the contour
levels.
*allsegs*: [level0segs, level1segs, ...]
List of all the polygon segments for all the *levels*.
For contour lines ``len(allsegs) == len(levels)``, and for
filled contour regions ``len(allsegs) = len(levels)-1``.
level0segs = [polygon0, polygon1, ...]
polygon0 = array_like [[x0,y0], [x1,y1], ...]
*allkinds*: *None* or [level0kinds, level1kinds, ...]
Optional list of all the polygon vertex kinds (code types), as
described and used in Path.   This is used to allow multiply-
connected paths such as holes within filled polygons.
If not *None*, len(allkinds) == len(allsegs).
level0kinds = [polygon0kinds, ...]
polygon0kinds = [vertexcode0, vertexcode1, ...]
If *allkinds* is not *None*, usually all polygons for a particular
contour level are grouped together so that
level0segs = [polygon0] and level0kinds = [polygon0kinds].
Keyword arguments are as described in
:attr:`matplotlib.contour.QuadContourSet.contour_doc`.'

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

    self.ax = ax
    self.levels = kwargs.get(u'levels', None)
    self.filled = kwargs.get(u'filled', False)
    self.linewidths = kwargs.get(u'linewidths', None)
    self.linestyles = kwargs.get(u'linestyles', None)
    self.hatches = kwargs.get(u'hatches', [None])
    self.alpha = kwargs.get(u'alpha', None)
    self.origin = kwargs.get(u'origin', None)
    self.extent = kwargs.get(u'extent', None)
    cmap = kwargs.get(u'cmap', None)
    self.colors = kwargs.get(u'colors', None)
    norm = kwargs.get(u'norm', None)
    vmin = kwargs.get(u'vmin', None)
    vmax = kwargs.get(u'vmax', None)
    self.extend = kwargs.get(u'extend', u'neither')
    self.antialiased = kwargs.get(u'antialiased', None)
    if ((self.antialiased is None) and self.filled):
        self.antialiased = False
    self.nchunk = kwargs.get(u'nchunk', 0)
    self.locator = kwargs.get(u'locator', None)
    if (isinstance(norm, colors.LogNorm) or isinstance(self.locator, ticker.LogLocator)):
        self.logscale = True
        if (norm is None):
            norm = colors.LogNorm()
        if (self.extend is not u'neither'):
            raise ValueError(u'extend    kwarg    does    not    work    yet    with    log        scale')
    else:
        self.logscale = False
    if (self.origin not in [None, u'lower', u'upper', u'image']):
        raise ValueError(u"If    given,    *origin*    must    be    one    of    [    'lower'    |    'upper'    |    'image']")
    if ((self.extent is not None) and (len(self.extent) != 4)):
        raise ValueError(u"If    given,    *extent*    must    be    '[    *None*    |    (x0,x1,y0,y1)    ]'")
    if ((self.colors is not None) and (cmap is not None)):
        raise ValueError(u'Either    colors    or    cmap    must    be    None')
    if (self.origin == u'image'):
        self.origin = mpl.rcParams[u'image.origin']
    self._transform = kwargs.get(u'transform', None)
    self._process_args(*args, **kwargs)
    self._process_levels()
    if (self.colors is not None):
        ncolors = len(self.levels)
        if self.filled:
            ncolors -= 1
        i0 = 0
        extend_min = (self.extend in [u'min', u'both'])
        extend_max = (self.extend in [u'max', u'both'])
        use_set_under_over = False
        total_levels = ((ncolors + int(extend_min)) + int(extend_max))
        if ((len(self.colors) == total_levels) and any([extend_min, extend_max])):
            use_set_under_over = True
            if extend_min:
                i0 = 1
        cmap = colors.ListedColormap(self.colors[i0:None], N=ncolors)
        if use_set_under_over:
            if extend_min:
                cmap.set_under(self.colors[0])
            if extend_max:
                cmap.set_over(self.colors[(-1)])
    if self.filled:
        self.collections = cbook.silent_list(u'mcoll.PathCollection')
    else:
        self.collections = cbook.silent_list(u'mcoll.LineCollection')
    self.labelTexts = []
    self.labelCValues = []
    kw = {u'cmap': cmap}
    if (norm is not None):
        kw[u'norm'] = norm
    cm.ScalarMappable.__init__(self, **kw)
    if (vmin is not None):
        self.norm.vmin = vmin
    if (vmax is not None):
        self.norm.vmax = vmax
    self._process_colors()
    (self.allsegs, self.allkinds) = self._get_allsegs_and_allkinds()
    if self.filled:
        if (self.linewidths is not None):
            warnings.warn(u'linewidths    is    ignored    by    contourf')
        (lowers, uppers) = self._get_lowers_and_uppers()
        if (self.allkinds is None):
            self.allkinds = ([None] * len(self.allsegs))
        for (level, level_upper, segs, kinds) in zip(lowers, uppers, self.allsegs, self.allkinds):
            paths = self._make_paths(segs, kinds)
            zorder = kwargs.get(u'zorder', 1)
            col = mcoll.PathCollection(paths, antialiaseds=(self.antialiased,), edgecolors=u'none', alpha=self.alpha, transform=self.get_transform(), zorder=zorder)
            self.ax.add_collection(col, autolim=False)
            self.collections.append(col)
    else:
        tlinewidths = self._process_linewidths()
        self.tlinewidths = tlinewidths
        tlinestyles = self._process_linestyles()
        aa = self.antialiased
        if (aa is not None):
            aa = (self.antialiased,)
        for (level, width, lstyle, segs) in zip(self.levels, tlinewidths, tlinestyles, self.allsegs):
            zorder = kwargs.get(u'zorder', 2)
            col = mcoll.LineCollection(segs, antialiaseds=aa, linewidths=width, linestyles=[lstyle], alpha=self.alpha, transform=self.get_transform(), zorder=zorder)
            col.set_label(u'_nolegend_')
            self.ax.add_collection(col, autolim=False)
            self.collections.append(col)
    for col in self.collections:
        col.sticky_edges.x[:] = [self._mins[0], self._maxs[0]]
        col.sticky_edges.y[:] = [self._mins[1], self._maxs[1]]
    self.ax.update_datalim([self._mins, self._maxs])
    self.ax.autoscale_view(tight=True)
    self.changed()
