title: How to add legend label in python animation
body: <p>I am plotting data (count) from database usling Matplotlib/Python. I cannot figure out how to have an animated legend. I want the legend to display the current value of the line.</p>
  
  <p>The code is:</p>
  
  <pre><code>def db_count():
      ### Connect to db and run query ...
      return count
  
  x_data, y_data = [], []
  figure = plt.figure()
  count = db_count()
  line, = plt.plot_date(x_data, y_data, '-', label=count)
  
  def update(frame):
      x_data.append(datetime.now())
      count = db_count()
      y_data.append(count)
      line.set_data(x_data, y_data)
      figure.gca().autoscale_view()
      figure.gca().relim()
      return line,
  
  animation = FuncAnimation(figure, update, interval=60000)
  
  plt.xlabel('Time')
  plt.ylabel('Counts')
  plt.title('Total counts')
  plt.legend(bbox_to_anchor=(1.05, 0.05))
  plt.gcf().autofmt_xdate()
  plt.xticks(rotation=45)
  plt.show()
  </code></pre>
  
  <p>Thanks</p>