matplotlib.patches.FancyBboxPatch#

class matplotlib.patches.FancyBboxPatch(xy, width, height, boxstyle='round', *, mutation_scale=1, mutation_aspect=1, **kwargs)[源代码][源代码]#

基类:Patch

围绕一个矩形的装饰框,左下角位于 xy = (x, y),具有指定的宽度和高度。

FancyBboxPatch 类似于 Rectangle,但它会在矩形周围绘制一个花哨的边框。矩形框到花哨边框的转换由 BoxStyle 中定义的样式类处理。

参数:
xy(浮点数, 浮点数)

盒子的左下角。

宽度float

盒子的宽度。

高度float

盒子的高度。

boxstyle : str 或 BoxStyle字符串或

花式框的样式。这可以是 BoxStyle 实例,也可以是样式名称和可选的逗号分隔属性的字符串(例如,“Round, pad=0.2”)。此字符串传递给 BoxStyle 以构造一个 BoxStyle 对象。有关完整文档,请参阅该部分。

以下是可用的框样式:

名称

Attrs

正方形

square

pad=0.3

circle

pad=0.3

椭圆

ellipse

pad=0.3

L箭头

larrow

pad=0.3

RArrow

rarrow

pad=0.3

DArrow

darrow

pad=0.3

round

pad=0.3, rounding_size=None

第四轮

round4

pad=0.3, rounding_size=None

锯齿

sawtooth

pad=0.3, tooth_size=None

圆齿

roundtooth

pad=0.3, tooth_size=None

mutation_scalefloat, 默认值: 1

应用于盒子样式属性的缩放因子(例如,填充或圆角大小)。

mutation_aspectfloat, 默认值: 1

矩形的高度将在突变前被此值压缩,而突变后的盒子将被其倒数拉伸。例如,这允许不同的水平和垂直填充。

其他参数:
**kwargs : Patch 属性补丁属性

属性

描述

agg_filter

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

alpha

未知

animated

布尔

抗锯齿 或 aa

布尔值或无

capstyle

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

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

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

颜色

color

edgecolor 或 ec

color or None

facecolor 或 fc

color or None

figure

FigureSubFigure

填充

布尔

gid

str

hatch

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

in_layout

布尔

joinstyle

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

标签

对象

linestyle 或 ls

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

linewidth 或 lw

浮点数或无

鼠标悬停

布尔

path_effects

AbstractPathEffect 列表

picker

None 或 bool 或 float 或 callable

光栅化

布尔

sketch_params

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

snap

布尔值或无

transform

Transform

url

str

可见

布尔

zorder

float

get_bbox()[源代码][源代码]#

返回 Bbox

get_boxstyle()[源代码][源代码]#

返回 boxstyle 对象。

get_height()[源代码][源代码]#

返回矩形的高度。

get_mutation_aspect()[源代码][源代码]#

返回 bbox 变形的纵横比。

get_mutation_scale()[源代码][源代码]#

返回突变比例。

get_path()[源代码][源代码]#

返回矩形的变异路径。

get_width()[源代码][源代码]#

返回矩形的宽度。

get_x()[源代码][源代码]#

返回矩形的左坐标。

get_y()[源代码][源代码]#

返回矩形的底部坐标。

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, bounds=<UNSET>, boxstyle=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, height=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, mutation_aspect=<UNSET>, mutation_scale=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, width=<UNSET>, x=<UNSET>, y=<UNSET>, zorder=<UNSET>)[源代码]#

一次性设置多个属性。

支持的属性是

属性

描述

agg_filter

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

alpha

标量或无

animated

布尔

抗锯齿 或 aa

布尔值或无

边界

未知

boxstyle

[ 'square' | 'circle' | 'ellipse' | 'larrow' | 'rarrow' | 'darrow' | 'round' | 'round4' | 'sawtooth' | 'roundtooth' ]

capstyle

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

clip_box

BboxBase 或 None

clip_on

布尔

clip_path

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

颜色

color

edgecolor 或 ec

color or None

facecolor 或 fc

color or None

figure

FigureSubFigure

填充

布尔

gid

str

hatch

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

高度

float

in_layout

布尔

joinstyle

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

标签

对象

linestyle 或 ls

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

linewidth 或 lw

浮点数或无

鼠标悬停

布尔

mutation_aspect

float

mutation_scale

float

path_effects

AbstractPathEffect 列表

picker

None 或 bool 或 float 或 callable

光栅化

布尔

sketch_params

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

snap

布尔值或无

transform

Transform

url

str

可见

布尔

宽度

float

x

float

y

float

zorder

float

set_bounds(*args)[源代码][源代码]#

设置矩形的边界。

调用签名:

set_bounds(left, bottom, width, height)
set_bounds((left, bottom, width, height))
参数:
左, 底float

矩形左下角的坐标。

宽度, 高度float

矩形的宽度/高度。

set_boxstyle(boxstyle=None, **kwargs)[源代码][源代码]#

设置框样式,可能带有进一步的属性。

不会重复使用前一个框样式中的属性。

没有参数(或使用 boxstyle=None),可用的框样式将作为人类可读的字符串返回。

参数:
boxstyle : str 或 BoxStyle字符串或

盒子的样式:可以是 BoxStyle 实例,或是一个字符串,该字符串是样式名称,并且可以选择性地以逗号分隔属性(例如,"Round,pad=0.2")。这样的字符串用于构造 BoxStyle 对象,如该类文档中所述。

以下是可用的框样式:

名称

Attrs

正方形

square

pad=0.3

circle

pad=0.3

椭圆

ellipse

pad=0.3

L箭头

larrow

pad=0.3

RArrow

rarrow

pad=0.3

DArrow

darrow

pad=0.3

round

pad=0.3, rounding_size=None

第四轮

round4

pad=0.3, rounding_size=None

锯齿

sawtooth

pad=0.3, tooth_size=None

圆齿

roundtooth

pad=0.3, tooth_size=None

**kwargs

盒样式的附加属性。请参阅上表以获取支持的参数。

示例

set_boxstyle("Round,pad=0.2")
set_boxstyle("round", pad=0.2)
set_height(h)[源代码][源代码]#

设置矩形的高度。

参数:
hfloat
set_mutation_aspect(aspect)[源代码][源代码]#

设置 bbox 变形的纵横比。

参数:
方面float
set_mutation_scale(scale)[源代码][源代码]#

设置变异比例。

参数:
比例float
set_width(w)[源代码][源代码]#

设置矩形的宽度。

参数:
wfloat
set_x(x)[源代码][源代码]#

设置矩形的左侧坐标。

参数:
xfloat
set_y(y)[源代码][源代码]#

设置矩形的底部坐标。

参数:
yfloat

使用 matplotlib.patches.FancyBboxPatch 的示例#

Matplotlib 艺术家的参考

Reference for Matplotlib artists

绘制花哨的框

Drawing fancy boxes