matplotlib.patches.Rectangle#
- class matplotlib.patches.Rectangle(xy, width, height, *, angle=0.0, rotation_point='xy', **kwargs)[源代码]#
基类:
Patch
一个通过锚点 xy 及其 宽度 和 高度 定义的矩形。
该矩形在 x 方向上从
xy[0]
延伸到xy[0] + width
,在 y 方向上从xy[1]
延伸到xy[1] + height
。: +------------------+ : | | : height | : | | : (xy)---- width -----+
可以将 xy 想象成左下角,但 *xy* 实际是哪个角取决于坐标轴的方向以及 *宽度* 和 *高度* 的正负;例如,如果 x 轴反转或 *宽度* 为负,*xy* 将是右下角。
- 参数:
- xy(float, float)
锚点。
- width浮点数
矩形宽度。
- heightfloat
矩形高度。
- anglefloat, 默认值: 0
围绕旋转点逆时针旋转的度数。
- rotation_point{'xy', 'center', (number, number)}, default: 'xy'
如果为 `'xy'`,则围绕锚点旋转。如果为 `'center'`,则围绕中心旋转。如果是数字的 2 元组,则围绕此坐标旋转。
- 其他参数:
- **kwargs
Patch
属性 属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
未知
布尔值
布尔值或 None
CapStyle
或 {'butt', 'projecting', 'round'}BboxBase
或 None布尔值
Patch 或 (Path, Transform) 或 None
颜色 或 None
颜色 或 None
布尔值
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
未知
布尔值
JoinStyle
或 {'miter', 'round', 'bevel'}object
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
浮点数或 None
布尔值
list of
AbstractPathEffect
None 或 布尔值 或 浮点数 或 可调用对象
布尔值
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
str
布尔值
浮点数
- **kwargs
- get_patch_transform()[源代码]#
返回将补丁坐标映射到数据坐标的
Transform
实例。例如,可以通过提供单位圆的坐标,并使用一个将坐标(补丁坐标)缩放5倍的变换,来定义一个表示半径为5的圆形补丁。
- property rotation_point#
补丁的旋转点。
- set(*, agg_filter=<UNSET>, alpha=<UNSET>, angle=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, bounds=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, height=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, width=<UNSET>, x=<UNSET>, xy=<UNSET>, y=<UNSET>, zorder=<UNSET>)[源代码]#
一次性设置多个属性。
支持的属性包括:
属性
描述
一个过滤函数,它接受一个 (m, n, 3) 浮点数组和一个 dpi 值,并返回一个 (m, n, 3) 数组以及图像左下角的两个偏移量
浮点数或 None
未知
布尔值
布尔值或 None
(左,下,宽,高)
CapStyle
或 {'butt', 'projecting', 'round'}BboxBase
或 None布尔值
Patch 或 (Path, Transform) 或 None
颜色 或 None
颜色 或 None
布尔值
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
未知
未知
布尔值
JoinStyle
或 {'miter', 'round', 'bevel'}object
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
浮点数或 None
布尔值
list of
AbstractPathEffect
None 或 布尔值 或 浮点数 或 可调用对象
布尔值
(scale: 浮点数, length: 浮点数, randomness: 浮点数)
布尔值或 None
str
布尔值
未知
未知
(浮点数, 浮点数)
未知
浮点数
- set_bounds(*args)[源代码]#
设置矩形的边界为 *左*、*下*、*宽度*、*高度*。
这些值可以作为单独的参数或作为元组传递。
set_bounds(left, bottom, width, height) set_bounds((left, bottom, width, height))
- property xy#
以元组形式返回矩形的左下坐标。