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: Find the point in the unfilled contour plot that is closest (in screen
  space) to point *xy*.
  
  Parameters
  ----------
  xy : tuple[float, float]
      The reference point (in screen space).
  indices : list of int or None, default: None
      Indices of contour levels to consider.  If None (the default), all levels
      are considered.
  
  Returns
  -------
  idx_level_min : int
      The index of the contour level closest to *xy*.
  idx_vtx_min : int
      The index of the `.Path` segment closest to *xy* (at that level).
  proj : (float, float)
      The point in the contour plot closest to *xy*.
docstr_tok: ["Find","the","point","in","the","unfilled","contour","plot","that","is","closest","(","in","screen","space",")","to","point","*","xy","*",".","Parameters","--","--","--","--","--","xy",":","tuple","[","float",",","float","]","The","reference","point","(","in","screen","space",")",".","indices",":","list","of","int","or","None",",","default",":","None","Indices","of","contour","levels","to","consider",".","If","None","(","the","default",")",",","all","levels","are","considered",".","Returns","--","--","--","-","idx_level_min",":","int","The","index","of","the","contour","level","closest","to","*","xy","*",".","idx_vtx_min",":","int","The","index","of","the","`",".Path","`","segment","closest","to","*","xy","*","(","at","that","level",")",".","proj",":","(","float",",","float",")","The","point","in","the","contour","plot","closest","to","*","xy","*","."]
code: def _find_nearest_contour(self, xy, indices=None):
      """
      Find the point in the unfilled contour plot that is closest (in screen
      space) to point *xy*.
  
      Parameters
      ----------
      xy : tuple[float, float]
          The reference point (in screen space).
      indices : list of int or None, default: None
          Indices of contour levels to consider.  If None (the default), all levels
          are considered.
  
      Returns
      -------
      idx_level_min : int
          The index of the contour level closest to *xy*.
      idx_vtx_min : int
          The index of the `.Path` segment closest to *xy* (at that level).
      proj : (float, float)
          The point in the contour plot closest to *xy*.
      """
  
      # Convert each contour segment to pixel coordinates and then compare the given
      # point to those coordinates for each contour. This is fast enough in normal
      # cases, but speedups may be possible.
  
      if self.filled:
          raise ValueError("Method does not support filled contours")
  
      if indices is None:
          indices = range(len(self._paths))
  
      d2min = np.inf
      idx_level_min = idx_vtx_min = proj_min = None
  
      for idx_level in indices:
          path = self._paths[idx_level]
          idx_vtx_start = 0
          for subpath in path._iter_connected_components():
              if not len(subpath.vertices):
                  continue
              lc = self.get_transform().transform(subpath.vertices)
              d2, proj, leg = _find_closest_point_on_path(lc, xy)
              if d2 < d2min:
                  d2min = d2
                  idx_level_min = idx_level
                  idx_vtx_min = leg[1] + idx_vtx_start
                  proj_min = proj
              idx_vtx_start += len(subpath)
  
      return idx_level_min, idx_vtx_min, proj_min
  
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 18 for calling the ContourSet obj's underlying member method code with example usage: obj._find_nearest_contour(xy, indices) and returns: idx_level_min,  idx_vtx_min,  proj_min