mpl.pyplot.Rectangle

class mpl.pyplot.Rectangle(xy, width, height, angle=0.0, **kwargs)[source]

Draw a rectangle with lower left at xy = (x, y) with specified width and height.

__init__(xy, width, height, angle=0.0, **kwargs)[source]
angle
rotation in degrees (anti-clockwise)

fill is a boolean indicating whether to fill the rectangle

Valid kwargs are:
agg_filter: unknown

alpha: float or None animated: [True | False] antialiased or aa: [True | False] or None for default axes: an Axes instance 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, or None for default, or ‘none’ for no color 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

Methods

__init__(xy, width, height[, angle]) angle
add_callback(func) Adds a callback function that will be called whenever one of the Artist‘s properties changes.
contains(mouseevent[, radius]) Test whether the mouse event occurred in the patch.
contains_point(point[, radius]) Returns True if the given point is inside the path (transformed with its transform attribute).
convert_xunits(x) For artists in an axes, if the xaxis has units support,
convert_yunits(y) For artists in an axes, if the yaxis has units support,
draw(artist, renderer, *args, **kwargs) Draw the Patch to the given renderer.
findobj([match, include_self]) Find artist objects.
format_cursor_data(data) Return cursor data string formatted.
get_aa() Returns True if the Patch is to be drawn with antialiasing.
get_agg_filter() return filter function to be used for agg filter
get_alpha() Return the alpha value used for blending - not supported on all
get_animated() Return the artist’s animated state
get_antialiased() Returns True if the Patch is to be drawn with antialiasing.
get_axes() Return the Axes instance the artist resides in, or None.
get_bbox()
get_capstyle() Return the current capstyle
get_children() Return a list of the child Artist`s this :class:`Artist contains.
get_clip_box() Return artist clipbox
get_clip_on() Return whether artist uses clipping
get_clip_path() Return artist clip path
get_contains() Return the _contains test used by the artist, or None for default.
get_cursor_data(event) Get the cursor data for a given event.
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_figure() Return the Figure instance the artist belongs to.
get_fill() return whether fill is set
get_gid() Returns the group id
get_hatch() Return the current hatching pattern
get_height() Return the height of the rectangle
get_joinstyle() Return the current joinstyle
get_label() Get the label used for this artist in the legend.
get_linestyle() Return the linestyle.
get_linewidth() Return the line width in points.
get_ls() Return the linestyle.
get_lw() Return the line width in points.
get_patch_transform()
get_path() Return the vertices of the rectangle
get_path_effects()
get_picker() Return the picker object used by this artist
get_rasterized() return True if the artist is to be rasterized
get_sketch_params() Returns the sketch parameters for the artist.
get_snap() Returns the snap setting which may be:
get_transform() Return the Transform applied to the Patch.
get_transformed_clip_path_and_affine() Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
get_url() Returns the url
get_verts() Return a copy of the vertices used in this patch
get_visible() Return the artist’s visiblity
get_width() Return the width of the rectangle
get_window_extent([renderer])
get_x() Return the left coord of the rectangle
get_xy() Return the left and bottom coords of the rectangle
get_y() Return the bottom coord of the rectangle
get_zorder() Return the Artist‘s zorder.
have_units() Return True if units are set on the x or y axes
hitlist(event) List the children of the artist which contain the mouse event event.
is_figure_set() Returns True if the artist is assigned to a Figure.
is_transform_set() Returns True if Artist has a transform explicitly set.
pchanged() Fire an event when property changed, calling all of the registered callbacks.
pick(mouseevent) call signature:
pickable() Return True if Artist is pickable.
properties() return a dictionary mapping property name -> value for all Artist props
remove() Remove the artist from the figure if possible.
remove_callback(oid) Remove a callback based on its id.
set(**kwargs) A property batch setter.
set_aa(aa) alias for set_antialiased
set_agg_filter(filter_func) set agg_filter fuction.
set_alpha(alpha) Set the alpha tranparency of the patch.
set_animated(b) Set the artist’s animation state.
set_antialiased(aa) Set whether to use antialiased rendering
set_axes(axes) Set the Axes instance in which the artist resides, if any.
set_bounds(*args) Set the bounds of the rectangle: l,b,w,h
set_capstyle(s) Set the patch capstyle
set_clip_box(clipbox) Set the artist’s clip Bbox.
set_clip_on(b) Set whether artist uses clipping.
set_clip_path(path[, transform]) Set the artist’s clip path, which may be:
set_color(c) Set both the edgecolor and the facecolor.
set_contains(picker) Replace the contains test used by this artist.
set_ec(color) alias for set_edgecolor
set_edgecolor(color) Set the patch edge color
set_facecolor(color) Set the patch face color
set_fc(color) alias for set_facecolor
set_figure(fig) Set the Figure instance the artist belongs to.
set_fill(b) Set whether to fill the patch
set_gid(gid) Sets the (group) id for the artist
set_hatch(hatch) Set the hatching pattern
set_height(h) Set the width rectangle
set_joinstyle(s) Set the patch joinstyle
set_label(s) Set the label to s for auto legend.
set_linestyle(ls) Set the patch linestyle
set_linewidth(w) Set the patch linewidth in points
set_ls(ls) alias for set_linestyle
set_lw(lw) alias for set_linewidth
set_path_effects(path_effects) set path_effects, which should be a list of instances of
set_picker(picker) Set the epsilon for picking used by this artist
set_rasterized(rasterized) Force rasterized (bitmap) drawing in vector backend output.
set_sketch_params([scale, length, randomness]) Sets the sketch parameters.
set_snap(snap) Sets the snap setting which may be:
set_transform(t) Set the Transform instance used by this artist.
set_url(url) Sets the url for the artist
set_visible(b) Set the artist’s visiblity.
set_width(w) Set the width rectangle
set_x(x) Set the left coord of the rectangle
set_xy(xy) Set the left and bottom coords of the rectangle
set_y(y) Set the bottom coord of the rectangle
set_zorder(level) Set the zorder for the artist.
update(props) Update the properties of this Artist from the dictionary prop.
update_from(other) Updates this Patch from the properties of other.

Attributes

aname
axes The Axes instance the artist resides in, or None.
fill return whether fill is set
mouseover
stale If the artist is ‘stale’ and needs to be re-drawn for the output to match the internal state of the artist.
validCap
validJoin
xy Return the left and bottom coords of the rectangle
zorder