matplotlib.figure.Figure#

classmatplotlib.figure.Figure(figsize=None,dpi=None,*,facecolor=None,edgecolor=None,linewidth=0.0,frameon=None,subplotpars=None,tight_layout=None,constrained_layout=None,layout=None,**kwargs)[source]#

The top level container for all the plot elements.

Seematplotlib.figure for an index of class methods.

Attributes:
patch

TheRectangle instance representing the figure background patch.

suppressComposite

For multiple images, the figure will make composite imagesdepending on the renderer option_image_nocomposite function. IfsuppressComposite is a boolean, this will override the renderer.

Parameters:
figsize(float, float) or (float, float, str), default:rcParams["figure.figsize"] (default:[6.4,4.8])

The figure dimensions. This can be

  • a tuple(width,height,unit), whereunit is one of "in" (inch),"cm" (centimenter), "px" (pixel).

  • a tuple(width,height), which is interpreted in inches, i.e. as(width,height,"in").

dpifloat, default:rcParams["figure.dpi"] (default:100.0)

Dots per inch.

facecolordefault:rcParams["figure.facecolor"] (default:'white')

The figure patch facecolor.

edgecolordefault:rcParams["figure.edgecolor"] (default:'white')

The figure patch edge color.

linewidthfloat

The linewidth of the frame (i.e. the edge linewidth of the figurepatch).

frameonbool, default:rcParams["figure.frameon"] (default:True)

IfFalse, suppress drawing the figure background patch.

subplotparsSubplotParams

Subplot parameters. If not given, the default subplotparametersrcParams["figure.subplot.*"] are used.

tight_layoutbool or dict, default:rcParams["figure.autolayout"] (default:False)

Whether to use the tight layout mechanism. Seeset_tight_layout.

Discouraged

The use of this parameter is discouraged. Please uselayout='tight' instead for the common case oftight_layout=True and useset_tight_layout otherwise.

constrained_layoutbool, default:rcParams["figure.constrained_layout.use"] (default:False)

This is equal tolayout='constrained'.

Discouraged

The use of this parameter is discouraged. Please uselayout='constrained' instead.

layout{'constrained', 'compressed', 'tight', 'none',LayoutEngine, None}, default: None

The layout mechanism for positioning of plot elements to avoidoverlapping Axes decorations (labels, ticks, etc). Note thatlayout managers can have significant performance penalties.

  • 'constrained': The constrained layout solver adjusts Axes sizesto avoid overlapping Axes decorations. Can handle complex plotlayouts and colorbars, and is thus recommended.

    SeeConstrained layout guide for examples.

  • 'compressed': uses the same algorithm as 'constrained', butremoves extra space between fixed-aspect-ratio Axes. Best forsimple grids of Axes.

  • 'tight': Use the tight layout mechanism. This is a relativelysimple algorithm that adjusts the subplot parameters so thatdecorations do not overlap.

    SeeTight layout guide for examples.

  • 'none': Do not use a layout engine.

  • ALayoutEngine instance. Builtin layout classes areConstrainedLayoutEngine andTightLayoutEngine, more easilyaccessible by 'constrained' and 'tight'. Passing an instanceallows third parties to provide their own layout engine.

If not given, fall back to using the parameterstight_layout andconstrained_layout, including their config defaultsrcParams["figure.autolayout"] (default:False) andrcParams["figure.constrained_layout.use"] (default:False).

Other Parameters:
**kwargsFigure properties, optional

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

canvas

FigureCanvas

clip_box

BboxBase or None

clip_on

bool

clip_path

Patch or (Path, Transform) or None

constrained_layout

unknown

constrained_layout_pads

unknown

dpi

float

edgecolor

color

facecolor

color

figheight

float

figure

unknown

figwidth

float

frameon

bool

gid

str

in_layout

bool

label

object

layout_engine

{'constrained', 'compressed', 'tight', 'none',LayoutEngine, None}

linewidth

number

mouseover

bool

path_effects

list ofAbstractPathEffect

picker

None or bool or float or callable

rasterized

bool

size_inches

(float, float) or float

sketch_params

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

snap

bool or None

tight_layout

unknown

transform

Transform

url

str

visible

bool

zorder

float

On this page