matplotlib.backends.backend_pdf
A PDF matplotlib backend Author: Jouni K Seppänen <jks@iki.fi>
-
matplotlib.backends.backend_pdf.FigureCanvas
-
alias of
FigureCanvasPdf
-
class matplotlib.backends.backend_pdf.FigureCanvasPdf(figure)
-
Bases:
matplotlib.backend_bases.FigureCanvasBase
The canvas the figure renders into. Calls the draw and print fig methods, creates the renderers, etc...
Public attribute
figure - A Figure instance
-
class matplotlib.backends.backend_pdf.Name(name)
-
Bases:
object
PDF name object.
-
class matplotlib.backends.backend_pdf.Operator(op)
-
Bases:
object
PDF operator object.
-
class matplotlib.backends.backend_pdf.PdfFile(filename)
-
Bases:
object
PDF file object.
-
alphaState(alpha)
-
Return name of an ExtGState that sets alpha to the given value
-
embedTTF(filename, characters)
-
Embed the TTF font from the named file into the document.
-
fontName(fontprop)
-
Select a font based on fontprop and return a name suitable for Op.selectfont. If fontprop is a string, it will be interpreted as the filename (or dvi name) of the font.
-
imageObject(image)
-
Return name of an image XObject representing the given image.
-
markerObject(path, trans, fill, stroke, lw, joinstyle, capstyle)
-
Return name of a marker XObject representing the given path.
-
reserveObject(name='')
-
Reserve an ID for an indirect object. The name is used for debugging in case we forget to print out the object with writeObject.
-
writeInfoDict()
-
Write out the info dictionary, checking it for good form
-
writeTrailer()
-
Write out the PDF trailer.
-
writeXref()
-
Write out the xref table.
-
-
class matplotlib.backends.backend_pdf.PdfPages(filename, keep_empty=True)
-
Bases:
object
A multi-page PDF file.
Notes
In reality
PdfPages
is a thin wrapper aroundPdfFile
, in order to avoid confusion when usingsavefig()
and forgetting the format argument.Examples
>>> import matplotlib.pyplot as plt >>> # Initialize: >>> with PdfPages('foo.pdf') as pdf: ... # As many times as you like, create a figure fig and save it: ... fig = plt.figure() ... pdf.savefig(fig) ... # When no figure is specified the current figure is saved ... pdf.savefig()
Create a new PdfPages object.
Parameters: filename: str
Plots using
PdfPages.savefig()
will be written to a file at this location. The file is opened at once and any older file with the same name is overwritten.keep_empty: bool, optional
If set to False, then empty pdf files will be deleted automatically when closed.
-
attach_note(text, positionRect=[-100, -100, 0, 0])
-
Add a new text note to the page to be saved next. The optional positionRect specifies the position of the new note on the page. It is outside the page per default to make sure it is invisible on printouts.
-
close()
-
Finalize this object, making the underlying file a complete PDF file.
-
get_pagecount()
-
Returns the current number of pages in the multipage pdf file.
-
infodict()
-
Return a modifiable information dictionary object (see PDF reference section 10.2.1 ‘Document Information Dictionary’).
-
savefig(figure=None, **kwargs)
-
Saves a
Figure
to this file as a new page.Any other keyword arguments are passed to
savefig()
.Parameters: figure: :class:`~matplotlib.figure.Figure` or int, optional
Specifies what figure is saved to file. If not specified, the active figure is saved. If a
Figure
instance is provided, this figure is saved. If an int is specified, the figure instance to save is looked up by number.
-
-
class matplotlib.backends.backend_pdf.Reference(id)
-
Bases:
object
PDF reference object. Use PdfFile.reserveObject() to create References.
-
class matplotlib.backends.backend_pdf.Stream(id, len, file, extra=None, png=None)
-
Bases:
object
PDF stream object.
This has no pdfRepr method. Instead, call begin(), then output the contents of the stream by calling write(), and finally call end().
id: object id of stream; len: an unused Reference object for the length of the stream, or None (to use a memory buffer); file: a PdfFile; extra: a dictionary of extra key-value pairs to include in the stream header; png: if the data is already png compressed, the decode parameters
-
end()
-
Finalize stream.
-
write(data)
-
Write some data on the stream.
-
-
class matplotlib.backends.backend_pdf.Verbatim(x)
-
Bases:
object
Store verbatim PDF command content for later inclusion in the stream.
-
matplotlib.backends.backend_pdf.fill(strings, linelen=75)
-
Make one string from sequence of strings, with whitespace in between. The whitespace is chosen to form lines of at most linelen characters, if possible.
-
matplotlib.backends.backend_pdf.new_figure_manager(num, *args, **kwargs)
-
Create a new figure manager instance
-
matplotlib.backends.backend_pdf.new_figure_manager_given_figure(num, figure)
-
Create a new figure manager instance for the given figure.
-
matplotlib.backends.backend_pdf.pdfRepr(obj)
-
Map Python objects to PDF syntax.
© 2012–2016 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
http://matplotlib.org/1.5.3/api/backend_pdf_api.html