matplotlib.backends.backend_svg
¶
-
matplotlib.backends.backend_svg.
FigureCanvas
¶
-
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'
. - str 或 str列表 :
'Contributor'
,'Creator'
,'Keywords'
,'Publisher'
和'Rights'
. - str , date , 日期时间 或 元组 相同的:
'Date'
. 如果是非- str ,则将其格式化为ISO 8601。
已为预定义值
'Creator'
,'Date'
,'Format'
和'Type'
. 可以通过将它们设置为None
.信息编码为 `Dublin Core Metadata`_ _.
- str :
-
-
class
matplotlib.backends.backend_svg.
RendererSVG
(width, height, svgwriter, basename=None, image_dpi=72, *, metadata=None)[源代码]¶ 基类:
matplotlib.backend_bases.RendererBase
-
draw_gouraud_triangle
(gc, points, colors, trans)[源代码]¶ 画一个古鲁德阴影三角形。
参数: - gc :
GraphicsContextBase
GraphicsContextBase
图形上下文。
- points类数组,形状=(3,2)
三角形的(x,y)点数组。
- colors类数组,形状=(3,4)
三角形每个点的rgba颜色。
- 转型 :
matplotlib.transforms.Transform
matplotlib.transforms.Transform
应用于点的仿射变换。
- gc :
-
draw_gouraud_triangles
(gc, triangles_array, colors_array, transform)[源代码]¶ 画一系列的古劳德三角形。
参数: - points类数组,形状=(N,3,2)
数组 N (x,y)三角形的点。
- colors类数组,形状=(N,3,4)
数组 N 每个三角形点的rgba颜色。
- 转型 :
matplotlib.transforms.Transform
matplotlib.transforms.Transform
应用于点的仿射变换。
-
draw_image
(gc, x, y, im, transform=None)[源代码]¶ 绘制RGBA图像。
参数: - gc :
GraphicsContextBase
GraphicsContextBase
包含剪辑信息的图形上下文。
- x标量
距离画布左侧的物理单位(即点或像素)。
- y标量
以物理单位(即点或像素)表示的与画布底部的距离。
- im类数组,shape=(N,M,4),数据类型=np.uint8公司
一组rgba像素。
- 转型 :
matplotlib.transforms.Affine2DBase
matplotlib.transforms.Affine2DBase
如果并且仅当具体的后端被写为
option_scale_image()
收益率True
,仿射变换(即Affine2DBase
) may 被传授给draw_image()
. 变换的平移向量以物理单位(即点或像素)给出。请注意,转换不会重写 x 和 y ,必须应用 之前 将结果转换为 x 和 y (这可以通过添加 x 和 y 到由定义的翻译矢量 转型 )
- gc :
-
draw_markers
(gc, marker_path, marker_trans, path, trans, rgbFace=None)[源代码]¶ 在路径中的每个顶点绘制一个标记。
这包括所有顶点,包括曲线上的控制点。为了避免这种行为,应该在调用此函数之前删除这些顶点。
这提供了一个draw_标记的回退实现,该标记对
draw_path()
. 有些后端可能希望重写此方法,以便只绘制一次标记并多次重复使用它。参数: - gc :
GraphicsContextBase
GraphicsContextBase
图形上下文。
- marker_trans :
matplotlib.transforms.Transform
matplotlib.transforms.Transform
应用于标记的仿射变换。
- 反式 :
matplotlib.transforms.Transform
matplotlib.transforms.Transform
应用于路径的仿射变换。
- gc :
-
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_text
(gc, x, y, s, prop, angle, ismath=False, mtext=None)[源代码]¶ 绘制文本实例。
参数: - gc :
GraphicsContextBase
GraphicsContextBase
图形上下文。
- x浮动
文本在显示坐标中的x位置。
- y浮动
文本基线在显示坐标中的y位置。
- sSTR
文本字符串。
- prop :
matplotlib.font_manager.FontProperties
matplotlib.font_manager.FontProperties
字体属性。
- angle浮动
以度为单位的逆时针旋转角度。
- 多行文本 :
matplotlib.text.Text
matplotlib.text.Text
要呈现的原始文本对象。
笔记
后端实现者注意:
当您试图确定边界框是否正确时(这是使文本布局/对齐方式正常工作的原因),它有助于更改文本中的线条。py::
if 0: bbox_artist(self, renderer)
如果为1,则实际边界框将与文本一起打印。
- gc :
-
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.
-
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可写文本文件类对象
-
element
(tag, text=None, attrib={}, **extra)[源代码]¶ 添加整个元素。这和打电话一样
start()
,data()
和end()
按顺序排列。这个 text 参数可以省略。