matplotlib.patches.Polygon#

class matplotlib.patches.Polygon(xy, *, closed=True, **kwargs)[源代码][源代码]#

基类:Patch

一个通用的多边形补丁。

参数:
xy(N, 2) 数组
关闭bool, 默认值: True

多边形是否闭合(即,起始点和终点相同)。

**kwargs

属性

描述

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'}

标签

对象

线型 或 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

浮动

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

返回多边形是否闭合。

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

获取多边形的 Path

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

获取路径的顶点。

返回:
(N, 2) 数组

顶点的坐标。

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, closed=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, gid=<UNSET>, hatch=<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>, xy=<UNSET>, zorder=<UNSET>)[源代码]#

一次性设置多个属性。

支持的属性有

属性

描述

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

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

closed

布尔

颜色

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'}

标签

对象

线型 或 ls

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

linewidth 或 lw

浮点数或无

鼠标悬停

布尔

path_effects

AbstractPathEffect 的列表

picker

None 或 bool 或 float 或 callable

光栅化

布尔

sketch_params

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

snap

布尔值或无

transform

Transform

url

str

可见

布尔

xy

(N, 2) 数组类

zorder

浮动

set_closed(closed)[源代码][源代码]#

设置多边形是否闭合。

参数:
关闭布尔

如果多边形是封闭的,则为真

set_xy(xy)[源代码][源代码]#

设置多边形的顶点。

参数:
xy(N, 2) 数组类

顶点的坐标。

注释

Path 不同,我们不会忽略最后一个输入顶点。如果多边形意味着要闭合,并且多边形的最后一个点不等于第一个点,我们假设用户没有显式传递一个 CLOSEPOLY 顶点,并自行添加它。

property xy#

路径的顶点作为 (N, 2) 数组。

使用 matplotlib.patches.Polygon 的示例#

使用边距和粘性边缘控制视图限制

Controlling view limits using margins and sticky_edges

箱线图

Boxplots

Arrow 指南

Arrow guide

Hatch 演示

Hatch demo

圆、楔形和多边形

Circles, Wedges and Polygons

floating_axes 功能

floating_axes features

积分作为曲线下的面积

Integral as the area under a curve

多边形编辑器

Polygon editor

Trifinder 事件演示

Trifinder Event Demo

石川图

Ishikawa Diagram

注解

Annotations