I'm trying to save my output (70+ graphs) from jyputer notebook into pdf file. No errors or whatsoever, but only the first graph is being exported. Can anyone please help me to understand what is wrong?
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.backends.backend_pdf
pdf = matplotlib.backends.backend_pdf.PdfPages("output.pdf")
df_num = df.select_dtypes(include = ['float64', 'int64'])
with PdfPages(r'output.pdf') as export_pdf:
fig = plt.figure(figsize=(12,12))
for col in df_num.columns:
hist = df_num[col].hist(bins=10)
print("Plotting for column {}".format(col))
plt.title("{}".format(col), fontsize=20)
plt.show()
export_pdf.savefig(fig)