matplotlib.patches.Ellipse#

class matplotlib.patches.Ellipse(xy, width, height, *, angle=0, **kwargs)[source]#

基类:Patch

一个无缩放的椭圆。

参数:
xy(float, float)

xy 椭圆中心的坐标。

width浮点数

水平轴的总长度(直径)。

heightfloat

垂直轴的总长度(直径)。

anglefloat, 默认值: 0

逆时针旋转的角度(以度为单位)。

备注

有效的关键字参数有:

属性

描述

agg_filter

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

alpha

未知

animated

布尔值

antialiasedaa

布尔值或 None

capstyle

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

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

color

color

edgecolorec

颜色 或 None

edgegapcolor

颜色 或 None

facecolorfc

颜色 或 None

figure

FigureSubFigure

fill

布尔值

gid

str

hatch

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

hatch_linewidth

未知

hatchcolor

color 或 'edge' 或 None

in_layout

布尔值

joinstyle

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

label

object

linestylels

{'-', '--', '-.', ':', '', ...} 或 (offset, on-off-seq)

linewidthlw

浮点数或 None

mouseover

布尔值

path_effects

AbstractPathEffect 列表

picker

None 或 布尔值 或 浮点数 或 可调用对象

rasterized

布尔值

sketch_params

(scale: 浮点数, length: 浮点数, randomness: 浮点数)

snap

布尔值或 None

transform

变换

url

str

visible

布尔值

zorder

浮点数

property angle#

返回椭圆的角度。

property center#

返回椭圆的中心。

get_angle()[source]#

返回椭圆的角度。

get_center()[source]#

返回椭圆的中心。

get_co_vertices()[source]#

返回椭圆共轭顶点的坐标。

定义可在此处找到 here

在版本 3.8 中添加。

get_corners()[source]#

返回椭圆边界框的角点。

边界框的方向从旋转前定义的左下角开始逆时针移动。

get_height()[source]#

返回椭圆的高度。

get_patch_transform()[source]#

返回将补丁坐标映射到数据坐标的 Transform 实例。

例如,可以通过提供单位圆的坐标,并使用一个将坐标(补丁坐标)缩放5倍的变换,来定义一个表示半径为5的圆形补丁。

get_path()[source]#

返回椭圆的路径。

get_vertices()[source]#

返回椭圆顶点的坐标。

定义可在此处找到 here

在版本 3.8 中添加。

get_width()[source]#

返回椭圆的宽度。

property height#

返回椭圆的高度。

set(*, agg_filter=<UNSET>, alpha=<UNSET>, angle=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, capstyle=<UNSET>, center=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, edgegapcolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<UNSET>, hatch_linewidth=<UNSET>, hatchcolor=<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>, zorder=<UNSET>)[source]#

一次性设置多个属性。

a.set(a=A, b=B, c=C)

等同于

a.set_a(A)
a.set_b(B)
a.set_c(C)

除全名属性外,还支持别名,例如 set(lw=2) 等同于 set(linewidth=2),但同时传入两者会报错。

各个 setter 的调用顺序与 set() 中的参数顺序一致。然而,大多数属性并不相互依赖,因此顺序通常无关紧要。

支持的属性包括:

属性

描述

agg_filter

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

alpha

浮点数或 None

angle

浮点数

animated

布尔值

antialiasedaa

布尔值或 None

capstyle

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

居中

(浮点数, 浮点数)

clip_box

BboxBase 或 None

clip_on

布尔值

clip_path

Patch 或 (Path, Transform) 或 None

color

color

edgecolorec

颜色 或 None

edgegapcolor

颜色 或 None

facecolorfc

颜色 或 None

figure

FigureSubFigure

fill

布尔值

gid

str

hatch

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

hatch_linewidth

未知

hatchcolor

color 或 'edge' 或 None

height

浮点数

in_layout

布尔值

joinstyle

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

label

object

linestylels

{'-', '--', '-.', ':', '', ...} 或 (offset, on-off-seq)

linewidthlw

浮点数或 None

mouseover

布尔值

path_effects

AbstractPathEffect 列表

picker

None 或 布尔值 或 浮点数 或 可调用对象

rasterized

布尔值

sketch_params

(scale: 浮点数, length: 浮点数, randomness: 浮点数)

snap

布尔值或 None

transform

变换

url

str

visible

布尔值

width

浮点数

zorder

浮点数

set_angle(angle)[source]#

设置椭圆的角度。

参数:
angle浮点数
set_center(xy)[source]#

设置椭圆的中心。

参数:
xy(float, float)
set_height(height)[source]#

设置椭圆的高度。

参数:
heightfloat
set_width(width)[source]#

设置椭圆的宽度。

参数:
width浮点数
property width#

返回椭圆的宽度。

使用 matplotlib.patches.Ellipse 的示例#

用补丁裁剪图像

用补丁裁剪图像

绘制二维数据集的置信椭圆

绘制二维数据集的置信椭圆

坐标轴框纵横比

坐标轴框纵横比

注释图表

注释图表

作为注释的艺术家对象

作为注释的艺术家对象

比例不变角度标签

比例不变角度标签

Matplotlib 艺术家参考

Matplotlib 艺术家参考

海豚

海豚

带方向箭头的椭圆演示

带方向箭头的椭圆演示

椭圆演示

椭圆演示

孵化图案演示

孵化图案演示

圆、扇形和多边形

圆、扇形和多边形

ggplot 样式表

ggplot 样式表

灰度样式表

灰度样式表

Petroff 样式表

Petroff 样式表

样式表参考

样式表参考

在三维图中绘制平面对象

在三维图中绘制平面对象

放大镜

放大镜

带单位的椭圆

带单位的椭圆

锚定艺术家

锚定艺术家

自定义投影

自定义投影

簇状气泡图

簇状气泡图

图形解剖

图形解剖

雷达图(又称蜘蛛图或星图)

雷达图(又称蜘蛛图或星图)

变换教程

变换教程

图例指南

图例指南

注解

注解