From 785f0d65daac96c087c8ee94534b51746347356b Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 30 Sep 2021 10:37:18 +0200 Subject: [PATCH] Shorten PdfPages FAQ entry. The original wording was inaccurate as both the pdf and pgf backends provide this functionality. I tried fixing that, but duplicating all links to both backends seemed unwieldy; additionally the "narrative" version of the FAQ reads worse (we should just encourage `pp.savefig()` instead of explaining that `plt.savefig()` needs workarounds, and also prefer `with PdfPages(...) as pp:`). Given that the docstring of both classes have examples, I just got rid of most of the FAQ entry instead (see also the next FAQ entries, which also have no code). --- doc/faq/howto_faq.rst | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/doc/faq/howto_faq.rst b/doc/faq/howto_faq.rst index 13d5412c985b..533e7d2b3141 100644 --- a/doc/faq/howto_faq.rst +++ b/doc/faq/howto_faq.rst @@ -110,33 +110,10 @@ on individual elements, e.g.:: Save multiple plots to one pdf file ----------------------------------- -Many image file formats can only have one image per file, but some -formats support multi-page files. Currently only the pdf backend has -support for this. To make a multi-page pdf file, first initialize the -file:: - - from matplotlib.backends.backend_pdf import PdfPages - pp = PdfPages('multipage.pdf') - -You can give the :class:`~matplotlib.backends.backend_pdf.PdfPages` -object to :func:`~matplotlib.pyplot.savefig`, but you have to specify -the format:: - - plt.savefig(pp, format='pdf') - -An easier way is to call -:meth:`PdfPages.savefig `:: - - pp.savefig() - -Finally, the multipage pdf object has to be closed:: - - pp.close() - -The same can be done using the pgf backend:: - - from matplotlib.backends.backend_pgf import PdfPages - +Many image file formats can only have one image per file, but some formats +support multi-page files. Currently, Matplotlib only provides multi-page +output to pdf files, using either the pdf or pgf backends, via the +`.backend_pdf.PdfPages` and `.backend_pgf.PdfPages` classes. .. _howto-auto-adjust: