1

I keep trying to follow the examples I see for PdfPages but keep getting the value error: No such figure: None.

plot1 = Chart Generating Function(argument1, argument2,...)

from matplotlib.backends.backend_pdf import PdfPages

pp = PdfPages('sample.pdf')
pp.savefig(plot1)
plt.close() 

I've tried different variations of this (i.e. pdf.savefig()) but nothing seems to work.

Dance Party
  • 3,459
  • 10
  • 42
  • 67
  • *Please post a runnable piece of code reproducing the problem.* With what you have now, the only piece of psychic advice I can offer is to check that your `Chart Generating Function` actually returns anything. – fjarri Nov 20 '15 at 04:00

2 Answers2

2

What solved the problem for me was removing the plt.show() command at the end of my chart generating function.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
0

I should have added more details, but somewhere in my code I had used "fig, ax = ..." when defining the figure. The "fig" part needed to be the argument in pdf.savefig(fig) in order for it to work.

Dance Party
  • 3,459
  • 10
  • 42
  • 67