matplotlib.patches.FancyBboxPatch — Matplotlib 3.10.3 documentation (original) (raw)

class matplotlib.patches.FancyBboxPatch(xy, width, height, boxstyle='round', *, mutation_scale=1, mutation_aspect=1, **kwargs)[source]#

Bases: Patch

A fancy box around a rectangle with lower left at xy = (x, y) with specified width and height.

FancyBboxPatch is similar to Rectangle, but it draws a fancy box around the rectangle. The transformation of the rectangle box to the fancy box is delegated to the style classes defined in BoxStyle.

Parameters:

xy(float, float)

The lower left corner of the box.

widthfloat

The width of the box.

heightfloat

The height of the box.

boxstylestr or BoxStyle

The style of the fancy box. This can either be a BoxStyleinstance or a string of the style name and optionally comma separated attributes (e.g. "Round, pad=0.2"). This string is passed to BoxStyle to construct a BoxStyle object. See there for a full documentation.

The following box styles are available:

mutation_scalefloat, default: 1

Scaling factor applied to the attributes of the box style (e.g. pad or rounding_size).

mutation_aspectfloat, default: 1

The height of the rectangle will be squeezed by this value before the mutation and the mutated box will be stretched by the inverse of it. For example, this allows different horizontal and vertical padding.

Other Parameters:

**kwargsPatch properties

get_bbox()[source]#

Return the Bbox.

get_boxstyle()[source]#

Return the boxstyle object.

get_height()[source]#

Return the height of the rectangle.

get_mutation_aspect()[source]#

Return the aspect ratio of the bbox mutation.

get_mutation_scale()[source]#

Return the mutation scale.

get_path()[source]#

Return the mutated path of the rectangle.

get_width()[source]#

Return the width of the rectangle.

get_x()[source]#

Return the left coord of the rectangle.

get_y()[source]#

Return the bottom coord of the rectangle.

set(*, agg_filter=, alpha=, animated=, antialiased=, bounds=, boxstyle=, capstyle=, clip_box=, clip_on=, clip_path=, color=, edgecolor=, facecolor=, fill=, gid=, hatch=, hatch_linewidth=, height=, in_layout=, joinstyle=, label=, linestyle=, linewidth=, mouseover=, mutation_aspect=, mutation_scale=, path_effects=, picker=, rasterized=, sketch_params=, snap=, transform=, url=, visible=, width=, x=, y=, zorder=)[source]#

Set multiple properties at once.

Supported properties are

set_bounds(*args)[source]#

Set the bounds of the rectangle.

Call signatures:

set_bounds(left, bottom, width, height) set_bounds((left, bottom, width, height))

Parameters:

left, bottomfloat

The coordinates of the bottom left corner of the rectangle.

width, heightfloat

The width/height of the rectangle.

set_boxstyle(boxstyle=None, **kwargs)[source]#

Set the box style, possibly with further attributes.

Attributes from the previous box style are not reused.

Without argument (or with boxstyle=None), the available box styles are returned as a human-readable string.

Parameters:

boxstylestr or BoxStyle

The style of the box: either a BoxStyle instance, or a string, which is the style name and optionally comma separated attributes (e.g. "Round,pad=0.2"). Such a string is used to construct aBoxStyle object, as documented in that class.

The following box styles are available:

**kwargs

Additional attributes for the box style. See the table above for supported parameters.

Examples

set_boxstyle("Round,pad=0.2") set_boxstyle("round", pad=0.2)

set_height(h)[source]#

Set the rectangle height.

Parameters:

hfloat

set_mutation_aspect(aspect)[source]#

Set the aspect ratio of the bbox mutation.

Parameters:

aspectfloat

set_mutation_scale(scale)[source]#

Set the mutation scale.

Parameters:

scalefloat

set_width(w)[source]#

Set the rectangle width.

Parameters:

wfloat

set_x(x)[source]#

Set the left coord of the rectangle.

Parameters:

xfloat

set_y(y)[source]#

Set the bottom coord of the rectangle.

Parameters:

yfloat

Examples using matplotlib.patches.FancyBboxPatch#