matplotlib.patches.ConnectionPatch#
- class matplotlib.patches.ConnectionPatch(xyA, xyB, coordsA, coordsB=None, *, axesA=None, axesB=None, arrowstyle='-', connectionstyle='arc3', patchA=None, patchB=None, shrinkA=0.0, shrinkB=0.0, mutation_scale=10.0, mutation_aspect=None, clip_on=False, **kwargs)[源代码][源代码]#
-
连接两个点(可能在不同的 Axes 中)的补丁。
将 coordsA 中的连接点 xyA 与 coordsB 中的连接点 xyB 连接起来。
有效的键是
键
描述
箭头样式
箭头样式
连接样式
连接样式
relpos
默认值为 (0.5, 0.5)
patchA
默认是文本的边界框
补丁B
默认值为 None
缩小A
默认是2点
缩小B
默认是2点
mutation_scale
默认是文本大小(以点为单位)
mutation_aspect
默认值为 1。
toctree
是一个 reStructuredText 指令 ,这是一个非常多功能的标记。指令可以有参数、选项和内容。coordsA 和 coordsB 是表示 xyA 和 xyB 坐标的字符串。
属性
描述
'figure points'
从图形的左下角开始计算的点
'figure 像素'
从图形的左下角开始的像素
'figure fraction'
0, 0 是图形的左下角,1, 1 是图形的右上角
'子图点'
从子图的左下角开始计算点
'子图像素'
子图左下角的像素
'子图比例'
子图的比例,0, 0 是左下角。
'轴点'
从Axes的左下角开始的点
'axes pixels'
从Axes的左下角开始的像素
'axes fraction'
0, 0 是 Axes 的左下角,1, 1 是 Axes 的右上角
'数据'
使用被注释对象的坐标系(默认)
'偏移点'
从 xy 值的偏移量(以点为单位)
'极地'
你可以在注释中指定 theta 和 r,即使在笛卡尔图中也是如此。请注意,如果你使用的是极坐标轴,你不需要为坐标系统指定极坐标,因为那是原生的“数据”坐标系统。
或者,它们可以设置为任何有效的
Transform
。注意,对于父图来说,'subfigure pixels' 和 'figure pixels' 是相同的,因此希望在子图中使用代码的用户可以使用 'subfigure pixels'。
备注
在两个
Axes
实例之间使用ConnectionPatch
与 约束布局 不直接兼容。将艺术家直接添加到Figure
而不是添加到特定的 Axes,或者使用con.set_in_layout(False)
将其从布局中排除。fig, ax = plt.subplots(1, 2, constrained_layout=True) con = ConnectionPatch(..., axesA=ax[0], axesB=ax[1]) fig.add_artist(con)
- draw(renderer)[源代码][源代码]#
使用给定的渲染器绘制艺术家(及其子元素)。
如果艺术家不可见(
Artist.get_visible
返回 False),则此操作无效。- 参数:
- 渲染器 :
RendererBase
子类。RendererBase 子类。
- 渲染器 :
注释
此方法在 Artist 子类中被重写。
- get_annotation_clip()[源代码][源代码]#
返回裁剪行为。
关于返回值的含义,请参见
set_annotation_clip
。
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, annotation_clip=<UNSET>, antialiased=<UNSET>, arrowstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, connectionstyle=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, patchA=<UNSET>, patchB=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, positions=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[源代码]#
一次性设置多个属性。
支持的属性有
属性
描述
一个过滤函数,它接收一个 (m, n, 3) 的浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量
标量或无
布尔
布尔值或无
抗锯齿
或 aa布尔值或无
[ '-' | '<-' | '->' | '<->' | '<|-' | '-|>' | '<|-|>' | ']-' | '-[' | ']-[' | '|-|' | ']->' | '<-[' | 'simple' | 'fancy' | 'wedge' ]
CapStyle
或 {'butt', 'projecting', 'round'}BboxBase
或 None布尔
补丁或(路径,变换)或无
[ 'arc3' | 'angle3' | 'angle' | 'arc' | 'bar' ]
edgecolor
或 eccolor or None
facecolor
或 fccolor or None
布尔
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
布尔
JoinStyle
或 {'miter', 'round', 'bevel'}对象
linestyle
或 ls{'-', '--', '-.', ':', '', (偏移, 开-关-序列), ...}
linewidth
或 lw浮点数或无
布尔
float
float
None 或 bool 或 float 或 callable
未知
布尔
(scale: float, length: float, randomness: float)
布尔值或无
str
布尔
float