title: Getting the legend label for a line in matplotlib
body: <p>Given that I have a line object in matplotlib, how do I get what the legend label will be for that line?</p>
  
  <p>The <code>get_label()</code> method of the Artist class only works if the legend did not change or create the label (using <code>plt.legend()</code> or similar).</p>
  
  <p>Getting the <em>handler</em> associated with a line is possible using <code>Legend.get_legend_handler()</code>, but that isn't associated with any text.  <code>Legend.get_lines()</code> gives a list of line objects... but they aren't the same objects that are plotted.</p>
  
  <p>An example of how <code>get_label()</code> doesn't work:</p>
  
  <pre><code>x = [0,1]
  y = [1,1]
  line, = plt.plot(x,y)
  plt.legend(("hello",))
  plt.plot()
  
  line.get_label() # returns '_line0'
  </code></pre>
  
  <p>Does anyone have any ideas?</p>