matplotlib.backends.backend_cairo

Matplotlib的开罗后端

作者:史蒂夫卓别林等人

这个后端依赖于cairocfi或pycairo。

matplotlib.backends.backend_cairo.FigureCanvas

alias of matplotlib.backends.backend_cairo.FigureCanvasCairo

class matplotlib.backends.backend_cairo.FigureCanvasCairo(figure)[源代码]

基类:matplotlib.backend_bases.FigureCanvasBase

copy_from_bbox(bbox)[源代码]
print_pdf(fobj, *args, **kwargs)[源代码]
print_png(fobj)[源代码]
print_ps(fobj, *args, **kwargs)[源代码]
print_raw(fobj)
print_rgba(fobj)[源代码]
print_svg(fobj, *args, **kwargs)[源代码]
print_svgz(fobj, *args, **kwargs)[源代码]
restore_region(region)[源代码]
class matplotlib.backends.backend_cairo.GraphicsContextCairo(renderer)[源代码]

基类:matplotlib.backend_bases.GraphicsContextBase

get_rgb()[源代码]

从0-1返回三个或四个浮点数的元组。

restore()[源代码]

从堆栈中恢复图形上下文-只需要在堆栈上保存图形上下文的后端。

set_alpha(alpha)[源代码]

设置用于混合的alpha值-不支持所有后端。

如果 alpha=None (默认),前景和填充颜色的alpha分量将用于设置各自的透明度(如果适用);否则, alpha 将覆盖它们。

set_capstyle(cs)[源代码]

将capstyle设置为(“butt”、“round”、“projecting”)之一。

set_clip_path(path)[源代码]

设置路径和剪辑。

参数:
pathTransformedPath 或无转换路径或无
set_clip_rectangle(rectangle)[源代码]

按顺序设置剪辑矩形(左、下、宽、高)

set_dashes(offset, dashes)[源代码]

设置gc的破折号样式。

参数:
dash_offset浮动或无

偏移量(通常为0)。

dash_list阵列式或无阵列

开关序列作为点。

笔记

(None, None) 指定实线。

见第107页至附言 blue book 更多信息。

set_foreground(fg, isRGBA=None)[源代码]

设置前景色。

参数:
fg颜色
isRGBA布尔

如果 fg 已知是 (r, g, b, a) 元组, 伊斯格巴 可以设置为True以提高性能。

set_joinstyle(js)[源代码]

将连接样式设置为('miter'、'round'、'bevel')之一。

set_linewidth(w)[源代码]

以点为单位设置线宽。

class matplotlib.backends.backend_cairo.RendererCairo(dpi)[源代码]

基类:matplotlib.backend_bases.RendererBase

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

绘制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, transform, 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_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,则实际边界框将与文本一起打印。

property fontangles
property fontweights
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.

new_gc()[源代码]

返回的实例 GraphicsContextBase .

points_to_pixels(points)[源代码]

将点转换为显示单位。

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

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

浮点数或浮点数数组

返回:
转换为像素的点
set_ctx_from_surface(surface)[源代码]
set_width_height(width, height)[源代码]