class_docstr: A cross-hair cursor that snaps to the data point of a line, which is
  closest to the *x* position of the cursor.
  
  For simplicity, this assumes that *x* values of the data are sorted.
class_docstr_tok: ["A","cross-hair","cursor","that","snaps","to","the","data","point","of","a","line",",","which","is","closest","to","the","*","x","*","position","of","the","cursor",".","For","simplicity",",","this","assumes","that","*","x","*","values","of","the","data","are","sorted","."]
code: def __init__(self, ax, line):
      self.ax = ax
      self.horizontal_line = ax.axhline(color="k", lw=0.8, ls="--")
      self.vertical_line = ax.axvline(color="k", lw=0.8, ls="--")
      self.x, self.y = line.get_data()
      self._last_index = None
      # text location in axes coords
      self.text = ax.text(0.72, 0.9, "", transform=ax.transAxes)
  
file_path: matplotlib/galleries/examples/event_handling/cursor_demo.py
imports: import matplotlib.pyplot
  import numpy
  from matplotlib.backend_bases import MouseEvent
label_desc: Use image node_id 1 to create a new SnappingCursor object  with example: obj = SnappingCursor(ax, line)