matplotlib.patches.Polygon#

classmatplotlib.patches.Polygon(xy,*,closed=True,**kwargs)[source]#

Bases:Patch

A general polygon patch.

Parameters:
xy(N, 2) array
closedbool, default: True

Whether the polygon is closed (i.e., has identical start and endpoints).

**kwargs

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image

alpha

unknown

animated

bool

antialiased oraa

bool or None

capstyle

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

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

color

color

edgecolor orec

color or None

facecolor orfc

color or None

figure

Figure orSubFigure

fill

bool

gid

str

hatch

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

hatch_linewidth

unknown

in_layout

bool

joinstyle

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

label

object

linestyle orls

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

linewidth orlw

float or None

mouseover

bool

path_effects

list ofAbstractPathEffect

picker

None or bool or float or callable

rasterized

bool

sketch_params

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

snap

bool or None

transform

Transform

url

str

visible

bool

zorder

float

get_closed()[source]#

Return whether the polygon is closed.

get_path()[source]#

Get thePath of the polygon.

get_xy()[source]#

Get the vertices of the path.

Returns:
(N, 2) array

The coordinates of the vertices.

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>,hatch_linewidth=<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>)[source]#

Set multiple properties at once.

Supported properties are

Property

Description

agg_filter

a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image

alpha

float or None

animated

bool

antialiased oraa

bool or None

capstyle

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

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

closed

bool

color

color

edgecolor orec

color or None

facecolor orfc

color or None

figure

Figure orSubFigure

fill

bool

gid

str

hatch

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

hatch_linewidth

unknown

in_layout

bool

joinstyle

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

label

object

linestyle orls

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

linewidth orlw

float or None

mouseover

bool

path_effects

list ofAbstractPathEffect

picker

None or bool or float or callable

rasterized

bool

sketch_params

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

snap

bool or None

transform

Transform

url

str

visible

bool

xy

(N, 2) array-like

zorder

float

set_closed(closed)[source]#

Set whether the polygon is closed.

Parameters:
closedbool

True if the polygon is closed

set_xy(xy)[source]#

Set the vertices of the polygon.

Parameters:
xy(N, 2) array-like

The coordinates of the vertices.

Notes

UnlikePath, we do not ignore the last input vertex. If thepolygon is meant to be closed, and the last point of the polygon is notequal to the first, we assume that the user has not explicitly passed aCLOSEPOLY vertex, and add it ourselves.

propertyxy#

The vertices of the path as a (N, 2) array.

Examples usingmatplotlib.patches.Polygon#

floating_axes features

floating_axes features

Polygon editor

Polygon editor

Trifinder Event Demo

Trifinder Event Demo

Arrow guide

Arrow guide

Hatch demo

Hatch demo

Circles, Wedges and Polygons

Circles, Wedges and Polygons

Integral as the area under a curve

Integral as the area under a curve

Ishikawa Diagram

Ishikawa Diagram

Boxplots

Boxplots

Controlling view limits using margins and sticky_edges

Controlling view limits using margins and sticky_edges

Annotations

Annotations