title: Create a legend with pandas and matplotlib.pyplot
body: <p>This is my first attempt at plotting with python and I'm having problems creating a legend.</p>
  
  <p>These are my imports:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import pandas
  </code></pre>
  
  <p>I load my data like this:</p>
  
  <pre><code>data = pandas.read_csv( 'data/output/limits.dat', sep=r"\s+", encoding = 'utf-8' )
  </code></pre>
  
  <p>and plot it like this:</p>
  
  <pre><code>axdata = data.plot( label = '$|U|^{2}$' , x = 'mass', y = 'U2',
                      style = '-s', markeredgecolor = 'none' )
  </code></pre>
  
  <p>Apparently axdata is now an  <code>AxesSubplot</code>.</p>
  
  <p>Now I want to create a legend as described <a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.legend">here</a> like this:</p>
  
  <pre><code>plt.legend( (line1), ('label1') )
  </code></pre>
  
  <p>but I don't know how to extract a <code>line</code> object from an <code>AxesSubplot</code></p>
  
  <p><code>plt.legend()</code> on its own works, but I only want some of my lines to feature in the legend. Is this the right approach? Is there another command I can use here?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>For example, if I try:</p>
  
  <pre><code>plt.legend( [axdata], ['U2'])
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>~/.virtualenvs/science/lib/python3.3/site-packages/matplotlib/legend.py:613:
  UserWarning: Legend does not support Axes(0.125,0.1;0.775x0.8)
  Use proxy artist instead.
  
  http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
  
  (str(orig_handle),))
  </code></pre>
  
  <p>I haven't worked out what a proxy artist is yet but I think it is a tool for when you are using a non-default graphical object, which I thought probably was not the case here because I am trying to produce a normal matlibplot plot. The words 'non-default' and 'normal' are mine - I'm not sure what they mean yet.</p>
  
  <p><strong>ANOTHER EDIT:</strong> (because I misread the comment )</p>
  
  <p><code>plt.legend()</code> on it's own doesn't output anything to the console but the resulting plot now has a legend auto-generated from the plotted data.</p>