matplotlib.backends.backend_svg

matplotlib.backends.backend_svg.FigureCanvas

alias of matplotlib.backends.backend_svg.FigureCanvasSVG

class matplotlib.backends.backend_svg.FigureCanvasSVG(figure)[源代码]

基类:matplotlib.backend_bases.FigureCanvasBase

filetypes = {'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics'}
fixed_dpi = 72
get_default_filetype()[源代码]

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

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

print_svg(filename, *args, **kwargs)[源代码]
参数:
filenamestr或path like或file like

输出目标;如果是字符串,将打开一个文件进行写入。

metadata双关语 [任何一个] 可选

SVG文件中的元数据定义为字符串的键值对、日期时间或字符串列表,例如。, {{'Creator': 'My software', 'Contributor': ['Me', 'My Friend'], 'Title': 'Awesome'}} .

标准键及其值类型为:

  • str'Coverage''Description''Format''Identifier''Language''Relation''Source''Title''Type' .
  • strstr列表'Contributor''Creator''Keywords''Publisher''Rights' .
  • strdate日期时间元组 相同的: 'Date' . 如果是非- str ,则将其格式化为ISO 8601。

已为预定义值 'Creator''Date''Format''Type' . 可以通过将它们设置为 None .

信息编码为 `Dublin Core Metadata`_ _.

print_svgz(filename, *args, **kwargs)[源代码]
class matplotlib.backends.backend_svg.RendererSVG(width, height, svgwriter, basename=None, image_dpi=72, *, metadata=None)[源代码]

基类:matplotlib.backend_bases.RendererBase

close_group(s)[源代码]

用标签关闭分组元素 s .

仅由SVG呈现器使用。

draw_gouraud_triangle(gc, points, colors, trans)[源代码]

画一个古鲁德阴影三角形。

参数:
gcGraphicsContextBaseGraphicsContextBase

图形上下文。

points类数组,形状=(3,2)

三角形的(x,y)点数组。

colors类数组,形状=(3,4)

三角形每个点的rgba颜色。

转型matplotlib.transforms.Transformmatplotlib.transforms.Transform

应用于点的仿射变换。

draw_gouraud_triangles(gc, triangles_array, colors_array, transform)[源代码]

画一系列的古劳德三角形。

参数:
points类数组,形状=(N,3,2)

数组 N (x,y)三角形的点。

colors类数组,形状=(N,3,4)

数组 N 每个三角形点的rgba颜色。

转型matplotlib.transforms.Transformmatplotlib.transforms.Transform

应用于点的仿射变换。

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_path_collection(gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)[源代码]

从列表中选择图形特性绘制路径集合 脸色绿色染料线宽度直线运动抗混叠剂 . 偏移量 是要应用于每个路径的偏移列表。中的偏移量 偏移量 首先被 抵销交易 在应用之前。

offset_position 可以是“屏幕”或“数据”,具体取决于偏移所处的空间;“数据”已弃用。

这提供了 draw_path_collection() 打了多次电话给 draw_path() . 有些后端可能希望重写此项,以便只渲染一次每个路径数据集,然后使用不同的偏移量、颜色、样式等多次引用该路径。生成器方法 _iter_collection_raw_paths()_iter_collection() 旨在帮助(和标准化)跨后端的实现。强烈建议使用这些生成器,以便更改 draw_path_collection() 可以在全球范围内生产。

draw_tex(gc, x, y, s, prop, angle, ismath=<deprecated parameter>, 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,则实际边界框将与文本一起打印。

finalize()[源代码]
flipy()[源代码]

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

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

get_canvas_width_height()[源代码]

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

get_image_magnification()[源代码]

获取放大传递给的图像的因子 draw_image() . 允许后端对其他艺术家使用不同分辨率的图像。

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.

open_group(s, gid=None)[源代码]

打开带标签的分组元素 sgid (如果设置)作为id。

仅由SVG呈现器使用。

option_image_nocomposite()[源代码]

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

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

option_scale_image()[源代码]

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

class matplotlib.backends.backend_svg.XMLWriter(file)[源代码]

基类:object

参数:
file可写文本文件类对象
close(id)[源代码]

关闭打开的元素,最多(包括)由给定标识符标识的元素。

参数:
id

元素标识符,由 start() 方法。

comment(comment)[源代码]

向输出流添加注释。

参数:
commentSTR

注释文本。

data(text)[源代码]

将字符数据添加到输出流。

参数:
textSTR

字符数据。

element(tag, text=None, attrib={}, **extra)[源代码]

添加整个元素。这和打电话一样 start()data()end() 按顺序排列。这个 text 参数可以省略。

end(tag=None, indent=True)[源代码]

关闭当前元素(由最近对的调用打开) start()

参数:
tag

元素标记。如果给定,则标记必须与起始标记匹配。如果省略,则当前元素将关闭。

flush()[源代码]

刷新输出流。

start(tag, attrib={}, **extra)[源代码]

打开新元素。属性可以作为关键字参数或字符串/字符串字典提供。该方法返回可传递给 close() 方法,关闭此元素之前(包括该元素)的所有打开元素。

参数:
tag

元素标记。

attrib

属性字典。或者,属性可以作为关键字参数给定。

返回:
元素标识符。
matplotlib.backends.backend_svg.escape_attrib(s)[源代码]
matplotlib.backends.backend_svg.escape_cdata(s)[源代码]
matplotlib.backends.backend_svg.escape_comment(s)[源代码]
matplotlib.backends.backend_svg.generate_css(attrib={})[源代码]
matplotlib.backends.backend_svg.generate_transform(transform_list=[])[源代码]
matplotlib.backends.backend_svg.short_float_fmt(x)[源代码]

创建一个浮点的短字符串表示形式,即%f格式,并删除尾随零和小数点。