matplotlib.backends.backend_pgf

matplotlib.backends.backend_pgf.FigureCanvas

alias of matplotlib.backends.backend_pgf.FigureCanvasPgf

class matplotlib.backends.backend_pgf.FigureCanvasPgf(figure)[源代码]

基类:matplotlib.backend_bases.FigureCanvasBase

filetypes = {'pdf': 'LaTeX compiled PGF picture', 'pgf': 'LaTeX PGF picture', 'png': 'Portable Network Graphics'}
get_default_filetype()[源代码]

返回中指定的默认savefig文件格式 rcParams["savefig.format"] (default: 'png') .

返回的字符串不包含句点。此方法在仅支持单一文件类型的后端中被重写。

get_renderer()[源代码]
print_pdf(fname_or_fh, *args, **kwargs)[源代码]

使用LaTex将PGF生成的图形编译为PDF。

print_pgf(fname_or_fh, *args, **kwargs)[源代码]

输出用于绘制图形的pgf宏,以便可以在latex文档中包含和呈现该图形。

print_png(fname_or_fh, *args, **kwargs)[源代码]

使用LaTex将PGF图编译为PDF并转换为PNG。

class matplotlib.backends.backend_pgf.GraphicsContextPgf[源代码]

基类:matplotlib.backend_bases.GraphicsContextBase

[Deprecated]

笔记

3.3 版后已移除:

exception matplotlib.backends.backend_pgf.LatexError(message, latex_output='')[源代码]

基类:Exception

class matplotlib.backends.backend_pgf.LatexManager[源代码]

基类:object

LatexManager打开一个LaTeX应用程序实例,用于确定文本元素的度量。可以通过在中设置字体和/或自定义前导来修改LaTeX环境 rcParams .

get_width_height_descent(text, prop)[源代码]

获取由当前LaTeX环境设置的文本类型的宽度、总高度和下降。

latex_stdin_utf8()[源代码]

[Deprecated]

笔记

3.3 版后已移除:

class matplotlib.backends.backend_pgf.PdfPages(filename, *, keep_empty=True, metadata=None)[源代码]

基类:object

使用PGF后端的多页PDF文件

实例

>>> 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()

创建新的pdfpages对象。

参数:
filenamestr或path-like

情节利用 PdfPages.savefig 将写入此位置的文件。任何同名的旧文件都将被覆盖。

keep_emptybool,默认值:True

如果设置为false,则关闭时将自动删除空的PDF文件。

metadata可选的

信息字典对象(参见PDF参考第10.2.1节“文档信息字典”),例如: {{'Creator': 'My software', 'Author': 'Me', 'Title': 'Awesome'}} .

标准键是“Title”、“Author”、“Subject”、“Keywords”、“Creator”、“Producer”、“CreationDate”、“ModDate”和“Trapped”。已经为“Creator”、“Producer”和“CreationDate”预定义了值。可以通过将其设置为 None .

close()[源代码]

完成此对象,在临时目录中运行LaTex并将最终的PDF文件移动到 文件名 .

get_pagecount()[源代码]

返回多页pdf文件中的当前页数。

keep_empty
property metadata
savefig(figure=None, **kwargs)[源代码]

保存 Figure 将此文件作为新页。

任何其他关键字参数都传递给 savefig .

参数:
图形Figure 或int,可选Figure或Int,可选

指定要保存到文件中的图形。如果未指定,则保存活动图形。如果A Figure 提供实例,保存此图。如果指定了int,将按数字查找要保存的图形实例。

class matplotlib.backends.backend_pgf.RendererPgf(figure, fh, dummy=<deprecated parameter>)[源代码]

基类:matplotlib.backend_bases.RendererBase

创建一个新的PGF渲染器,将任何绘图指令转换为文本命令,以便在latex pgfpicture环境中进行解释。

属性:
图形matplotlib.figure.Figurematplotlib.figure.Figure

Matplotlib图初始化高度、宽度和dpi。

fh类文件

图形命令输出的文件句柄。

draw_image(gc, x, y, im, transform=None)[源代码]

绘制RGBA图像。

参数:
gcGraphicsContextBaseGraphicsContextBase

包含剪辑信息的图形上下文。

x标量

距离画布左侧的物理单位(即点或像素)。

y标量

以物理单位(即点或像素)表示的与画布底部的距离。

im类数组,shape=(N,M,4),数据类型=np.uint8公司

一组rgba像素。

转型matplotlib.transforms.Affine2DBasematplotlib.transforms.Affine2DBase

如果并且仅当具体的后端被写为 option_scale_image() 收益率 True ,仿射变换(即 Affine2DBasemay 被传授给 draw_image() . 变换的平移向量以物理单位(即点或像素)给出。请注意,转换不会重写 xy ,必须应用 之前 将结果转换为 xy (这可以通过添加 xy 到由定义的翻译矢量 转型

draw_markers(gc, marker_path, marker_trans, path, trans, rgbFace=None)[源代码]

在路径中的每个顶点绘制一个标记。

这包括所有顶点,包括曲线上的控制点。为了避免这种行为,应该在调用此函数之前删除这些顶点。

这提供了一个draw_标记的回退实现,该标记对 draw_path() . 有些后端可能希望重写此方法,以便只绘制一次标记并多次重复使用它。

参数:
gcGraphicsContextBaseGraphicsContextBase

图形上下文。

marker_transmatplotlib.transforms.Transformmatplotlib.transforms.Transform

应用于标记的仿射变换。

反式matplotlib.transforms.Transformmatplotlib.transforms.Transform

应用于路径的仿射变换。

draw_path(gc, path, transform, rgbFace=None)[源代码]

画一个 Path 使用给定仿射变换的实例。

draw_tex(gc, x, y, s, prop, angle, ismath='TeX!', mtext=None)[源代码]
draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[源代码]

绘制文本实例。

参数:
gcGraphicsContextBaseGraphicsContextBase

图形上下文。

x浮动

文本在显示坐标中的x位置。

y浮动

文本基线在显示坐标中的y位置。

sSTR

文本字符串。

propmatplotlib.font_manager.FontPropertiesmatplotlib.font_manager.FontProperties

字体属性。

angle浮动

以度为单位的逆时针旋转角度。

多行文本matplotlib.text.Textmatplotlib.text.Text

要呈现的原始文本对象。

笔记

后端实现者注意:

当您试图确定边界框是否正确时(这是使文本布局/对齐方式正常工作的原因),它有助于更改文本中的线条。py::

if 0: bbox_artist(self, renderer)

如果为1,则实际边界框将与文本一起打印。

flipy()[源代码]

返回y值是否从上到下递增。

请注意,这只影响文本和图像的绘制。

get_canvas_width_height()[源代码]

返回显示坐标中的画布宽度和高度。

get_text_width_height_descent(s, prop, ismath)[源代码]

Get the width, height, and descent (offset from the bottom to the baseline), in display coords, of the string s with FontProperties prop.

property latexManager
option_image_nocomposite()[源代码]

返回是否应跳过Matplotlib合成图像。

栅格后端通常应返回False(让C级栅格化器负责图像合成);矢量后端通常应返回 not rcParams["image.composite_image"] .

option_scale_image()[源代码]

返回是否在 draw_image() 支持(对于大多数向量后端为真)。

points_to_pixels(points)[源代码]

将点转换为显示单位。

您需要重写这个函数(除非您的后端没有dpi,例如postscript或svg)。一些成像系统假定每英寸像素的值为:

points to pixels = points * pixels_per_inch/72 * dpi/72
参数:
points浮点数或类似数组的

浮点数或浮点数数组

返回:
转换为像素的点
class matplotlib.backends.backend_pgf.TmpDirCleaner[源代码]

基类:object

static add(tmpdir)[源代码]
static cleanup_remaining_tmpdirs()[源代码]
remaining_tmpdirs = {}
matplotlib.backends.backend_pgf.common_texification(text)[源代码]

对要包含在 Latex 文档中的文本进行一些必要和/或有用的替换。

这通过替换数学分隔符来区分文本模式和数学模式 $ 具有 \(\displaystyle %s\) . 转义数学分隔符 (\$ 被忽略。

以下字符在文本段中转义: _^$%

matplotlib.backends.backend_pgf.get_fontspec()[源代码]

从RC构建fontspec前言。

matplotlib.backends.backend_pgf.get_preamble()[源代码]

从RC获取 Latex 前言。

matplotlib.backends.backend_pgf.make_pdf_to_png_converter()[源代码]

返回将pdf文件转换为png文件的函数。

matplotlib.backends.backend_pgf.repl_escapetext(m)[源代码]

[Deprecated]

笔记

3.2 版后已移除:

matplotlib.backends.backend_pgf.repl_mathdefault(m)[源代码]

[Deprecated]

笔记

3.2 版后已移除:

matplotlib.backends.backend_pgf.writeln(fh, line)[源代码]