I created a program which generates a large number of chart using seaborn catplot. This is the example of my code with the illustration of how the final chart looks like.
plot= sns.catplot(data=df3, x="solutions", y="score", col="subject", col_wrap=3, hue="Value",height=3, aspect=1.5,legend=False, sharex=False, sharey=False)
plt.legend(loc='upper left')
plot.set_xticklabels(rotation=90)
plt.tight_layout()
#Create output
plot.savefig("output3.pdf")
However since the plot may extend up to more than 300 plots, when I tried to export to pdf, the size of the chart is too big and big part of the plot get cropped out. I notice there are only 1 pages for this pdf output. Is there a way to create a multiple pages for this output?
EDIT:
As suggested by comments, I'm trying to use PdfPages
import matplotlib.backends.backend_pdf
pdf = matplotlib.backends.backend_pdf.PdfPages("output.pdf")
for fig in range(1, plt.gcf().number + 1):
plot= sns.catplot(data=df3, x="solutions", y="score", col="subject", col_wrap=3, hue="Value",height=3, aspect=1.5,legend=False, sharex=False, sharey=False)
plt.legend(loc='upper left')
plot.set_xticklabels(rotation=90)
plt.tight_layout()
pdf.savefig( fig )
pdf.close()
But it return error message:
<Figure size 432x288 with 0 Axes>
and return with pdf document with blank pages inside. Please help as I may not aware which part I did it wrongly
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…