title: In the given mention code I want the real values of X and Y while hover mouse on the line graph how can i do?
body: <p>code: here in the given code I want the actuall X and Y values in the text of annotate while hover the mouse over the line graph . so what changes i do please help me.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np; np.random.seed(1)
  
  x = np.sort(np.random.rand(15))
  y = np.sort(np.random.rand(15))
  names = np.array(list("ABCDEFGHIJKLMNO"))
  
  fig,ax = plt.subplots()
  line, = plt.plot(x,y, marker="o")
  
  annot = ax.annotate("", xy=(0,0), xytext=(-20,20),textcoords="offset points",
                      bbox=dict(boxstyle="round", fc="w"),
                      arrowprops=dict(arrowstyle="-&gt;"))
  annot.set_visible(False)
  
  def update_annot(ind):
      x,y = line.get_data()
      annot.xy = (x[ind["ind"][0]], y[ind["ind"][0]])
      text = "{}, {}".format(" ".join(list(map(str,ind["ind"]))), 
                             " ".join([names[n] for n in ind["ind"]]))
      annot.set_text(text)
      annot.get_bbox_patch().set_alpha(0.4)
  
  
  def hover(event):
      vis = annot.get_visible()
      if event.inaxes == ax:
          cont, ind = line.contains(event)
          if cont:
              update_annot(ind)
              annot.set_visible(True)
              fig.canvas.draw_idle()
          else:
              if vis:
                  annot.set_visible(False)
                  fig.canvas.draw_idle()
  
  fig.canvas.mpl_connect("motion_notify_event", hover)
  
  plt.show()
  </code></pre>