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)[source]#
-
连接两个点(可能在不同坐标系中)的补丁。
连接 coordsA 中的点 xyA 和 coordsB 中的点 xyB。
有效键为
键
描述
arrowstyle(箭头样式)
箭头样式
connectionstyle(连接样式)
连接样式
relpos(相对位置)
默认为 (0.5, 0.5)
patchA
默认为文本的边界框
patchB
默认为 None
shrinkA
默认为 2 点
shrinkB
默认为 2 点
mutation_scale(突变比例)
默认为文本大小(以点为单位)
mutation_aspect(突变纵横比)
默认为 1。
?
适用于
matplotlib.patches.PathPatch
的任何键coordsA 和 coordsB 是字符串,指示 xyA 和 xyB 的坐标。
属性
描述
'figure points'(图形点)
从图形左下角算起的点
'figure pixels'(图形像素)
从图形左下角算起的像素
'figure fraction'(图形比例)
0, 0 是图形左下角,1, 1 是右上角
'subfigure points'(子图点)
从子图左下角算起的点
'subfigure pixels'(子图像素)
从子图左下角算起的像素
'subfigure fraction'(子图比例)
子图的比例,0, 0 是左下角。
'axes points'(坐标系点)
从坐标系左下角算起的点
'axes pixels'(坐标系像素)
从坐标系左下角算起的像素
'axes fraction'(坐标系比例)
0, 0 是坐标系左下角,1, 1 是右上角
'data'(数据)
使用被标注对象的坐标系(默认)
'offset points'(偏移点)
从 xy 值偏移(以点为单位)
'polar'(极坐标)
您可以为标注指定 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)[source]#
使用给定的渲染器绘制 Artist(及其子对象)。
如果艺术家不可见(
Artist.get_visible
返回 False),则此操作无效。- 参数:
- renderer
RendererBase
子类。
- renderer
备注
此方法在 Artist 子类中被覆盖。
- get_annotation_clip()[source]#
返回裁剪行为。
有关返回值的含义,请参阅
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>, hatch_linewidth=<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>)[source]#
一次性设置多个属性。
支持的属性包括:
属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
布尔值
布尔值或 None
antialiased
或aa
(抗锯齿)布尔值或 None
[ '-' | '<-' | '->' | '<->' | '<|-' | '-|>' | '<|-|>' | ']-' | '-[' | ']-[' | '|-|' | ']->' | '<-[' | 'simple' | 'fancy' | 'wedge' ]
CapStyle
或 {'butt', 'projecting', 'round'}BboxBase
或 None布尔值
Patch 或 (Path, Transform) 或 None
[ 'arc3' | 'angle3' | 'angle' | 'arc' | 'bar' ]
颜色 或 None
颜色 或 None
布尔值
str(字符串)
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
未知
布尔值
JoinStyle
或 {'miter', 'round', 'bevel'}object(对象)
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
浮点数或 None
布尔值
浮点数
浮点数
None 或 布尔值 或 浮点数 或 可调用对象
未知
布尔值
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
str(字符串)
布尔值
浮点数