title: Saving plots (AxesSubPlot) generated from python pandas with matplotlib's savefig
body: <p>I'm using pandas to generate a plot from a dataframe, which I would like to save to a file:</p>
  
  <pre><code>dtf = pd.DataFrame.from_records(d,columns=h)
  fig = plt.figure()
  ax = dtf2.plot()
  ax = fig.add_subplot(ax)
  fig.savefig('~/Documents/output.png')
  </code></pre>
  
  <p>It seems like the last line, using matplotlib's savefig, should do the trick.  But that code produces the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./testgraph.py", line 76, in &lt;module&gt;
      ax = fig.add_subplot(ax)
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 890, in add_subplot
      assert(a.get_figure() is self)
  AssertionError
  </code></pre>
  
  <p>Alternatively, trying to call savefig directly on the plot also errors out:</p>
  
  <pre><code>dtf2.plot().savefig('~/Documents/output.png')
  
  
    File "./testgraph.py", line 79, in &lt;module&gt;
      dtf2.plot().savefig('~/Documents/output.png')
  AttributeError: 'AxesSubplot' object has no attribute 'savefig'
  </code></pre>
  
  <p>I think I need to somehow add the subplot returned by plot() to a figure in order to use savefig.  I also wonder if perhaps this has to do with the <a href="https://stackoverflow.com/questions/11690597/there-is-a-class-matplotlib-axes-axessubplot-but-the-module-matplotlib-axes-has">magic</a> behind the AxesSubPlot class.</p>
  
  <p>EDIT: </p>
  
  <p>the following works (raising no error), but leaves me with a blank page image....</p>
  
  <pre><code>fig = plt.figure()
  dtf2.plot()
  fig.savefig('output.png')
  </code></pre>
  
  <p>EDIT 2:
  The below code works fine as well</p>
  
  <pre><code>dtf2.plot().get_figure().savefig('output.png')
  </code></pre>