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)[源代码][源代码]#

基类:FancyArrowPatch

连接两个点(可能在不同的 Axes 中)的补丁。

coordsA 中的连接点 xyAcoordsB 中的连接点 xyB 连接起来。

有效的键是

描述

箭头样式

箭头样式

连接样式

连接样式

relpos

默认值为 (0.5, 0.5)

patchA

默认是文本的边界框

补丁B

默认值为 None

缩小A

默认是2点

缩小B

默认是2点

mutation_scale

默认是文本大小(以点为单位)

mutation_aspect

默认值为 1。

toctree 是一个 reStructuredText 指令 ,这是一个非常多功能的标记。指令可以有参数、选项和内容。

matplotlib.patches.PathPatch 的任何键

coordsAcoordsB 是表示 xyAxyB 坐标的字符串。

属性

描述

'figure points'

从图形的左下角开始计算的点

'figure 像素'

从图形的左下角开始的像素

'figure fraction'

0, 0 是图形的左下角,1, 1 是图形的右上角

'子图点'

从子图的左下角开始计算点

'子图像素'

子图左下角的像素

'子图比例'

子图的比例,0, 0 是左下角。

'轴点'

从Axes的左下角开始的点

'axes pixels'

从Axes的左下角开始的像素

'axes fraction'

0, 0 是 Axes 的左下角,1, 1 是 Axes 的右上角

'数据'

使用被注释对象的坐标系(默认)

'偏移点'

xy 值的偏移量(以点为单位)

'极地'

你可以在注释中指定 thetar,即使在笛卡尔图中也是如此。请注意,如果你使用的是极坐标轴,你不需要为坐标系统指定极坐标,因为那是原生的“数据”坐标系统。

或者,它们可以设置为任何有效的 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>)[源代码]#

一次性设置多个属性。

支持的属性有

属性

描述

agg_filter

一个过滤函数,它接收一个 (m, n, 3) 的浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组和两个从图像左下角开始的偏移量

alpha

标量或无

animated

布尔

annotation_clip

布尔值或无

抗锯齿 或 aa

布尔值或无

arrowstyle

[ '-' | '<-' | '->' | '<->' | '<|-' | '-|>' | '<|-|>' | ']-' | '-[' | ']-[' | '|-|' | ']->' | '<-[' | 'simple' | 'fancy' | 'wedge' ]

capstyle

CapStyle 或 {'butt', 'projecting', 'round'}

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

补丁或(路径,变换)或无

颜色

color

connectionstyle

[ 'arc3' | 'angle3' | 'angle' | 'arc' | 'bar' ]

edgecolor 或 ec

color or None

facecolor 或 fc

color or None

figure

FigureSubFigure

fill

布尔

gid

str

hatch

{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}

in_layout

布尔

joinstyle

JoinStyle 或 {'miter', 'round', 'bevel'}

标签

对象

linestyle 或 ls

{'-', '--', '-.', ':', '', (偏移, 开-关-序列), ...}

linewidth 或 lw

浮点数或无

鼠标悬停

布尔

mutation_aspect

float

mutation_scale

float

patchA

patches.Patch

patchB

patches.Patch

path_effects

AbstractPathEffect 列表

picker

None 或 bool 或 float 或 callable

positions

未知

栅格化

布尔

sketch_params

(scale: float, length: float, randomness: float)

snap

布尔值或无

transform

Transform

url

str

可见

布尔

zorder

float

set_annotation_clip(b)[源代码][源代码]#

设置注释的裁剪行为。

参数:
b布尔值或无
  • True: 当 self.xy 超出 Axes 时,注释将被裁剪。

  • False: 注释将始终被绘制。

  • None: 当 self.xy 位于 Axes 之外且 self.xycoords == "data" 时,注释将被裁剪。

使用 matplotlib.patches.ConnectionPatch 的示例#

饼图条

Bar of pie

多轴动画

Multiple Axes animation

约束布局指南

Constrained layout guide

注解

Annotations