class_docstr: Store a set of contour lines or filled regions.
  
  User-callable method: `~.Axes.clabel`
  
  Parameters
  ----------
  ax : `~matplotlib.axes.Axes`
  
  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``. The lists
      should look like ::
  
          level0segs = [polygon0, polygon1, ...]
          polygon0 = [[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)``. The lists
      should look like ::
  
          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]``.
  
  **kwargs
      Keyword arguments are as described in the docstring of
      `~.Axes.contour`.
  
  %(contour_set_attributes)s
class_docstr_tok: ["Store","a","set","of","contour","lines","or","filled","regions",".","User-callable","method",":","`","~.Axes.clabel","`","Parameters","--","--","--","--","--","ax",":","`","~matplotlib.axes.Axes","`","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","``",".","The","lists","should","look","like",":",":","level0segs","=","[","polygon0",",","polygon1",",","...","]","polygon0","=","[","[","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",")","``",".","The","lists","should","look","like",":",":","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","]","``",".","*","*","kwargs","Keyword","arguments","are","as","described","in","the","docstring","of","`","~.Axes.contour","`",".","%","(","contour_set_attributes",")","s"]
docstr: Draw contour lines or filled regions, depending on
  whether keyword arg *filled* is ``False`` (default) or ``True``.
  
  Call signature::
  
      ContourSet(ax, levels, allsegs, [allkinds], **kwargs)
  
  Parameters
  ----------
  ax : `~matplotlib.axes.Axes`
      The `~.axes.Axes` object to draw on.
  
  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``. The lists
      should look like ::
  
          level0segs = [polygon0, polygon1, ...]
          polygon0 = [[x0, y0], [x1, y1], ...]
  
  allkinds : [level0kinds, level1kinds, ...], optional
      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)``. The lists
      should look like ::
  
          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]``.
  
  **kwargs
      Keyword arguments are as described in the docstring of
      `~.Axes.contour`.
docstr_tok: ["Draw","contour","lines","or","filled","regions",",","depending","on","whether","keyword","arg","*","filled","*","is","``","False","``","(","default",")","or","``","True","``",".","Call","signature",":",":","ContourSet","(","ax",",","levels",",","allsegs",",","[","allkinds","]",",","*","*","kwargs",")","Parameters","--","--","--","--","--","ax",":","`","~matplotlib.axes.Axes","`","The","`","~.axes.Axes","`","object","to","draw","on",".","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","``",".","The","lists","should","look","like",":",":","level0segs","=","[","polygon0",",","polygon1",",","...","]","polygon0","=","[","[","x0",",","y0","]",",","[","x1",",","y1","]",",","...","]","allkinds",":","[","level0kinds",",","level1kinds",",","...","]",",","optional","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",")","``",".","The","lists","should","look","like",":",":","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","]","``",".","*","*","kwargs","Keyword","arguments","are","as","described","in","the","docstring","of","`","~.Axes.contour","`","."]
code: def __init__(
      self,
      ax,
      *args,
      levels=None,
      filled=False,
      linewidths=None,
      linestyles=None,
      hatches=(None,),
      alpha=None,
      origin=None,
      extent=None,
      cmap=None,
      colors=None,
      norm=None,
      vmin=None,
      vmax=None,
      extend="neither",
      antialiased=None,
      nchunk=0,
      locator=None,
      transform=None,
      negative_linestyles=None,
      clip_path=None,
      **kwargs,
  ):
      """
      Draw contour lines or filled regions, depending on
      whether keyword arg *filled* is ``False`` (default) or ``True``.
  
      Call signature::
  
          ContourSet(ax, levels, allsegs, [allkinds], **kwargs)
  
      Parameters
      ----------
      ax : `~matplotlib.axes.Axes`
          The `~.axes.Axes` object to draw on.
  
      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``. The lists
          should look like ::
  
              level0segs = [polygon0, polygon1, ...]
              polygon0 = [[x0, y0], [x1, y1], ...]
  
      allkinds : [level0kinds, level1kinds, ...], optional
          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)``. The lists
          should look like ::
  
              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]``.
  
      **kwargs
          Keyword arguments are as described in the docstring of
          `~.Axes.contour`.
      """
      if antialiased is None and filled:
          # Eliminate artifacts; we are not stroking the boundaries.
          antialiased = False
          # The default for line contours will be taken from the
          # LineCollection default, which uses :rc:`lines.antialiased`.
      super().__init__(
          antialiaseds=antialiased,
          alpha=alpha,
          clip_path=clip_path,
          transform=transform,
      )
      self.axes = ax
      self.levels = levels
      self.filled = filled
      self.hatches = hatches
      self.origin = origin
      self.extent = extent
      self.colors = colors
      self.extend = extend
  
      self.nchunk = nchunk
      self.locator = locator
      if isinstance(norm, mcolors.LogNorm) or isinstance(
          self.locator, ticker.LogLocator
      ):
          self.logscale = True
          if norm is None:
              norm = mcolors.LogNorm()
      else:
          self.logscale = False
  
      _api.check_in_list(
          [None, "lower", "upper", "image"], origin=origin
      )
      if self.extent is not None and len(self.extent) != 4:
          raise ValueError(
              "If given, 'extent' must be None or (x0, x1, y0, y1)"
          )
      if self.colors is not None and cmap is not None:
          raise ValueError("Either colors or cmap must be None")
      if self.origin == "image":
          self.origin = mpl.rcParams["image.origin"]
  
      self._orig_linestyles = linestyles  # Only kept for user access.
      self.negative_linestyles = negative_linestyles
      # If negative_linestyles was not defined as a keyword argument, define
      # negative_linestyles with rcParams
      if self.negative_linestyles is None:
          self.negative_linestyles = mpl.rcParams[
              "contour.negative_linestyle"
          ]
  
      kwargs = self._process_args(*args, **kwargs)
      self._process_levels()
  
      self._extend_min = self.extend in ["min", "both"]
      self._extend_max = self.extend in ["max", "both"]
      if self.colors is not None:
          ncolors = len(self.levels)
          if self.filled:
              ncolors -= 1
          i0 = 0
  
          # Handle the case where colors are given for the extended
          # parts of the contour.
  
          use_set_under_over = False
          # if we are extending the lower end, and we've been given enough
          # colors then skip the first color in the resulting cmap. For the
          # extend_max case we don't need to worry about passing more colors
          # than ncolors as ListedColormap will clip.
          total_levels = (
              ncolors + int(self._extend_min) + int(self._extend_max)
          )
          if len(self.colors) == total_levels and (
              self._extend_min or self._extend_max
          ):
              use_set_under_over = True
              if self._extend_min:
                  i0 = 1
  
          cmap = mcolors.ListedColormap(self.colors[i0:None], N=ncolors)
  
          if use_set_under_over:
              if self._extend_min:
                  cmap.set_under(self.colors[0])
              if self._extend_max:
                  cmap.set_over(self.colors[-1])
  
      # label lists must be initialized here
      self.labelTexts = []
      self.labelCValues = []
  
      self.set_cmap(cmap)
      if norm is not None:
          self.set_norm(norm)
      with self.norm.callbacks.blocked(signal="changed"):
          if vmin is not None:
              self.norm.vmin = vmin
          if vmax is not None:
              self.norm.vmax = vmax
      self.norm._changed()
      self._process_colors()
  
      if self._paths is None:
          self._paths = self._make_paths_from_contour_generator()
  
      if self.filled:
          if linewidths is not None:
              _api.warn_external("linewidths is ignored by contourf")
          # Lower and upper contour levels.
          lowers, uppers = self._get_lowers_and_uppers()
          self.set(
              edgecolor="none",
              # Default zorder taken from Collection
              zorder=kwargs.pop("zorder", 1),
          )
  
      else:
          self.set(
              facecolor="none",
              linewidths=self._process_linewidths(linewidths),
              linestyle=self._process_linestyles(linestyles),
              # Default zorder taken from LineCollection, which is higher
              # than for filled contours so that lines are displayed on top.
              zorder=kwargs.pop("zorder", 2),
              label="_nolegend_",
          )
  
      self.axes.add_collection(self, autolim=False)
      self.sticky_edges.x[:] = [self._mins[0], self._maxs[0]]
      self.sticky_edges.y[:] = [self._mins[1], self._maxs[1]]
      self.axes.update_datalim([self._mins, self._maxs])
      self.axes.autoscale_view(tight=True)
  
      self.changed()  # set the colors
  
      if kwargs:
          _api.warn_external(
              "The following kwargs were not used by contour: "
              + ", ".join(map(repr, kwargs))
          )
  
imports: from contextlib import ExitStack
  import functools
  import math
  from numbers import Integral
  import numpy
  from numpy import ma
  import matplotlib
  from matplotlib import _api, _docstring
  from matplotlib.backend_bases import MouseButton
  from matplotlib.lines import Line2D
  from matplotlib.path import Path
  from matplotlib.text import Text
  import matplotlib.ticker
  import matplotlib.cm
  import matplotlib.colors
  import matplotlib.collections
  import matplotlib.font_manager
  import matplotlib.cbook
  import matplotlib.patches
  import matplotlib.transforms
label_desc: Use image node_id 1 to create a new ContourSet object from inherited base classes: ContourLabeler, mcoll with example: obj = ContourSet(ax)