You are reading an old version of the documentation (v2.1.0). For the latest version see https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html
matplotlib
Fork me on GitHub


Travis-CI:

Table Of Contents

This Page

matplotlib.patches.Patch

class matplotlib.patches.Patch(edgecolor=None, facecolor=None, color=None, linewidth=None, linestyle=None, antialiased=None, hatch=None, fill=True, capstyle=None, joinstyle=None, **kwargs)

A patch is a 2D artist with a face color and an edge color.

If any of edgecolor, facecolor, linewidth, or antialiased are None, they default to their rc params setting.

The following kwarg properties are supported

Property Description
agg_filter unknown
alpha float or None
animated [True | False]
antialiased or aa [True | False] or None for default
capstyle [‘butt’ | ‘round’ | ‘projecting’]
clip_box a matplotlib.transforms.Bbox instance
clip_on [True | False]
clip_path [ (Path, Transform) | Patch | None ]
color matplotlib color spec
contains a callable function
edgecolor or ec mpl color spec, None, ‘none’, or ‘auto’
facecolor or fc mpl color spec, or None for default, or ‘none’ for no color
figure a matplotlib.figure.Figure instance
fill [True | False]
gid an id string
hatch [‘/’ | ‘' | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’]
joinstyle [‘miter’ | ‘round’ | ‘bevel’]
label string or anything printable with ‘%s’ conversion.
linestyle or ls [‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ | (offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
linewidth or lw float or None for default
path_effects unknown
picker [None|float|boolean|callable]
rasterized [True | False | None]
sketch_params unknown
snap unknown
transform Transform instance
url a url string
visible [True | False]
zorder any number
contains(mouseevent, radius=None)

Test whether the mouse event occurred in the patch.

Returns T/F, {}

contains_point(point, radius=None)

Returns True if the given point is inside the path (transformed with its transform attribute).

draw(renderer)

Draw the Patch to the given renderer.

fill

return whether fill is set

get_aa()

Returns True if the Patch is to be drawn with antialiasing.

get_antialiased()

Returns True if the Patch is to be drawn with antialiasing.

get_capstyle()

Return the current capstyle

get_data_transform()

Return the Transform instance which maps data coordinates to physical coordinates.

get_ec()

Return the edge color of the Patch.

get_edgecolor()

Return the edge color of the Patch.

get_extents()

Return a Bbox object defining the axis-aligned extents of the Patch.

get_facecolor()

Return the face color of the Patch.

get_fc()

Return the face color of the Patch.

get_fill()

return whether fill is set

get_hatch()

Return the current hatching pattern

get_joinstyle()

Return the current joinstyle

get_linestyle()

Return the linestyle. Will be one of [‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’]

get_linewidth()

Return the line width in points.

get_ls()

Return the linestyle. Will be one of [‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’]

get_lw()

Return the line width in points.

get_patch_transform()

Return the Transform instance which takes patch coordinates to data coordinates.

For example, one may define a patch of a circle which represents a radius of 5 by providing coordinates for a unit circle, and a transform which scales the coordinates (the patch coordinate) by 5.

get_path()

Return the path of this patch

get_transform()

Return the Transform applied to the Patch.

get_verts()

Return a copy of the vertices used in this patch

If the patch contains Bezier curves, the curves will be interpolated by line segments. To access the curves as curves, use get_path().

get_window_extent(renderer=None)
set_aa(aa)

alias for set_antialiased

set_alpha(alpha)

Set the alpha tranparency of the patch.

ACCEPTS: float or None

set_antialiased(aa)

Set whether to use antialiased rendering

ACCEPTS: [True | False] or None for default

set_capstyle(s)

Set the patch capstyle

ACCEPTS: [‘butt’ | ‘round’ | ‘projecting’]

set_color(c)

Set both the edgecolor and the facecolor.

ACCEPTS: matplotlib color spec

See also

set_facecolor(), set_edgecolor()
For setting the edge or face color individually.
set_ec(color)

alias for set_edgecolor

set_edgecolor(color)

Set the patch edge color

ACCEPTS: mpl color spec, None, ‘none’, or ‘auto’

set_facecolor(color)

Set the patch face color

ACCEPTS: mpl color spec, or None for default, or ‘none’ for no color

set_fc(color)

alias for set_facecolor

set_fill(b)

Set whether to fill the patch

ACCEPTS: [True | False]

set_hatch(hatch)

Set the hatching pattern

hatch can be one of:

/   - diagonal hatching
\   - back diagonal
|   - vertical
-   - horizontal
+   - crossed
x   - crossed diagonal
o   - small circle
O   - large circle
.   - dots
*   - stars

Letters can be combined, in which case all the specified hatchings are done. If same letter repeats, it increases the density of hatching of that pattern.

Hatching is supported in the PostScript, PDF, SVG and Agg backends only.

ACCEPTS: [‘/’ | ‘' | ‘|’ | ‘-‘ | ‘+’ | ‘x’ | ‘o’ | ‘O’ | ‘.’ | ‘*’]

set_joinstyle(s)

Set the patch joinstyle

ACCEPTS: [‘miter’ | ‘round’ | ‘bevel’]

set_linestyle(ls)

Set the patch linestyle

linestyle description
'-' or 'solid' solid line
'--' or 'dashed' dashed line
'-.' or 'dashdot' dash-dotted line
':' or 'dotted' dotted line

Alternatively a dash tuple of the following form can be provided:

(offset, onoffseq),

where onoffseq is an even length tuple of on and off ink in points.

ACCEPTS: [‘solid’ | ‘dashed’, ‘dashdot’, ‘dotted’ |
(offset, on-off-dash-seq) | '-' | '--' | '-.' | ':' | 'None' | ' ' | '']
Parameters:

ls : { ‘-‘, ‘–’, ‘-.’, ‘:’} and more see description

The line style.

set_linewidth(w)

Set the patch linewidth in points

ACCEPTS: float or None for default

set_ls(ls)

alias for set_linestyle

set_lw(lw)

alias for set_linewidth

update_from(other)

Updates this Patch from the properties of other.

validCap = ('butt', 'round', 'projecting')
validJoin = ('miter', 'round', 'bevel')
zorder = 1

Examples using matplotlib.patches.Patch