Skip to content

Backport PR #21229 on branch v3.5.x (Shorten PdfPages FAQ entry.) #21233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions doc/faq/howto_faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <matplotlib.backends.backend_pdf.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:

Expand Down