0

I am trying to plot a dataframe as a table and save it to pdf. I am able to save figures to pdf using this example https://matplotlib.org/examples/pylab_examples/multipage_pdf.html. I can also plot the table I want but not save it to pdf. : enter image description here

I an trying with

fig_stats = plt.figure(figsize=(12, 9))
fig_stats = ff.create_table(df_stats)
plt.title('Derived features')
#txt = 'this is an example'
plt.text(0.05, 0.95, txt, transform=fig_stats.transFigure, size=24)
pdf.savefig()
plt.close()

but I am not allowed to save this to a pdf, I get AttributeError: 'Figure' object has no attribute 'transFigure' I also tried with Matplotlibs own table generator, but neither works. I would really appreciate being able to use the PdfPages package as I also need to plot some figures in the same pdf. Any ideas as to what I am doing wrong ? Thanks in advance

MyTivoli
  • 125
  • 2
  • 11
  • 1
    Does this answers your question https://stackoverflow.com/questions/33155776/export-pandas-dataframe-into-a-pdf-file-using-python? – Anvar Kurmukov Aug 15 '20 at 10:55
  • 1
    Does this answer your question? [Export Pandas DataFrame into a PDF file using Python](https://stackoverflow.com/questions/33155776/export-pandas-dataframe-into-a-pdf-file-using-python) – Anvar Kurmukov Aug 15 '20 at 10:56
  • Hi! this link https://stackoverflow.com/questions/32137396/how-do-i-plot-only-a-table-in-matplotlib got it to work ! not quite as nice as the table using create_table but it works! Thanks – MyTivoli Aug 15 '20 at 11:28

0 Answers0