title: How to annotate the values of X and Y while hovering mouse over the bar graph
body: <p>I have tried to make it but while executing, it shows me the following error:</p>
  
  <pre><code>bar,=plt.bar(xpos,revenue)
  </code></pre>
  
  <blockquote>
    <p>ValueError: too many values to unpack</p>
  </blockquote>
  
  <p>how can i solve it as i want values of <code>x</code> and <code>y</code> in the annotate while hover mouse. This is my following code:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  company=['google','amazon','msft','fb']
  revenue=[80,68,54,27]
  
  fig=plt.figure()
  ax=plt.subplot()
  
  xpos=np.arange(len(company))
  
  bar,=plt.bar(xpos,revenue)
  
  
  annot = ax.annotate("", xy=(0,0), xytext=(-20,20),textcoords="offset points",
                      bbox=dict(boxstyle="round", fc="black", ec="b", lw=2),
                      arrowprops=dict(arrowstyle="-&gt;"))
  annot.set_visible(False)
  
  def update_annot(ind):
      x,y = bar.get_data()
      x0 = x[ind["ind"][0]]
      y0 = y[ind["ind"][0]]
      annot.xy = (x0, y0)
      text = "({:.2g},{:.2g})".format(
          x0,y0,
      )
      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 = bar.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>