class_docstr: A crosshair cursor like `~matplotlib.widgets.Cursor` with a text showing     the current coordinates.
  
  For the cursor to remain responsive you must keep a reference to it.
  The data of the axis specified as *dataaxis* must be in ascending
  order. Otherwise, the `numpy.searchsorted` call might fail and the text
  disappears. You can satisfy the requirement by sorting the data you plot.
  Usually the data is already sorted (if it was created e.g. using
  `numpy.linspace`), but e.g. scatter plots might cause this problem.
  The cursor sticks to the plotted line.
  
  Parameters
  ----------
  line : `matplotlib.lines.Line2D`
      The plot line from which the data coordinates are displayed.
  
  numberformat : `python format string <https://docs.python.org/3/    library/string.html#formatstrings>`_, optional, default: "{0:.4g};{1:.4g}"
      The displayed text is created by calling *format()* on this string
      with the two coordinates.
  
  offset : (float, float) default: (5, 5)
      The offset in display (pixel) coordinates of the text position
      relative to the cross-hair.
  
  dataaxis : {"x", "y"}, optional, default: "x"
      If "x" is specified, the vertical cursor line sticks to the mouse
      pointer. The horizontal cursor line sticks to *line*
      at that x value. The text shows the data coordinates of *line*
      at the pointed x value. If you specify "y", it works in the opposite
      manner. But: For the "y" value, where the mouse points to, there might
      be multiple matching x values, if the plotted function is not biunique.
      Cursor and text coordinate will always refer to only one x value.
      So if you use the parameter value "y", ensure that your function is
      biunique.
  
  Other Parameters
  ----------------
  textprops : `matplotlib.text` properties as dictionary
      Specifies the appearance of the rendered text object.
  
  **cursorargs : `matplotlib.widgets.Cursor` properties
      Arguments passed to the internal `~matplotlib.widgets.Cursor` instance.
      The `matplotlib.axes.Axes` argument is mandatory! The parameter
      *useblit* can be set to *True* in order to achieve faster rendering.
code: def __init__(
      self,
      line,
      numberformat="{0:.4g};{1:.4g}",
      offset=(5, 5),
      dataaxis="x",
      textprops=None,
      **cursorargs,
  ):
      if textprops is None:
          textprops = {}
      # The line object, for which the coordinates are displayed
      self.line = line
      # The format string, on which .format() is called for creating the text
      self.numberformat = numberformat
      # Text position offset
      self.offset = np.array(offset)
      # The axis in which the cursor position is looked up
      self.dataaxis = dataaxis
  
      # First call baseclass constructor.
      # Draws cursor and remembers background for blitting.
      # Saves ax as class attribute.
      super().__init__(**cursorargs)
  
      # Default value for position of text.
      self.set_position(
          self.line.get_xdata()[0], self.line.get_ydata()[0]
      )
      # Create invisible animated text
      self.text = self.ax.text(
          self.ax.get_xbound()[0],
          self.ax.get_ybound()[0],
          "0, 0",
          animated=bool(self.useblit),
          visible=False,
          **textprops,
      )
      # The position at which the cursor was last drawn
      self.lastdrawnplotpoint = None
  
file_path: matplotlib/galleries/examples/widgets/annotated_cursor.py
imports: import matplotlib.pyplot
  import numpy
  from matplotlib.backend_bases import MouseEvent
  from matplotlib.widgets import Cursor
label_desc: Use image node_id 1 to create a new AnnotatedCursor object from inherited base classes: Cursor with example: obj = AnnotatedCursor(line, numberformat, offset, dataaxis, textprops)