Error when trying to write a matplotlib plot from Pandas DataFrame to pdf
<p>I'm trying to write a plot from matplotlib to a pdf file but getting an error. </p>

<p>I'm creating a plot using matplotlib from a Pandas DataFrame like this:</p>

<pre><code>bplot = dfbuild.plot(x='Build',kind='barh',stacked='True')
</code></pre>

<p>From the documentation: <a href="http://matplotlib.org/faq/howto_faq.html#save-multiple-plots-to-one-pdf-file" rel="nofollow">http://matplotlib.org/faq/howto_faq.html#save-multiple-plots-to-one-pdf-file</a></p>

<p>It seems like I should be doing it this way:</p>

<pre><code>from matplotlib.backends.backend_pdf import PdfPages
pp = PdfPages(r'c:\temp\page.pdf')
figure = bplot.fig
pp.savefig(figure)
pp.close()
</code></pre>

<p>I get this error: </p>

<pre><code>AttributeError: 'AxesSubplot' object has no attribute 'fig'
</code></pre>

<p>I works when I do it this way.</p>

<pre><code>pp = PdfPages(r'c:\temp\page.pdf')
dfbuild.plot(x=['Build','Opperator'],kind='barh',stacked='True')
pp.savefig()
pp.close()
</code></pre>

<p>From <a href="http://stackoverflow.com/questions/21364405/saving-plots-to-pdf-files-using-matplotlib">Saving plots to pdf files using matplotlib</a></p>

python pandas matplotlib plot pdfpages