Create a new figure, or activate an existing figure.
Figure or SubFigure, optional
A unique identifier for the figure.
If a figure with that identifier already exists, this figure is made active and returned. An integer refers to the Figure.number attribute, a string refers to the figure label.
If there is no figure with the identifier or num is not given, a new figure is created, made active and returned. If num is an int, it will be used for the Figure.number attribute, otherwise, an auto-generated integer value is used (starting at 1 and incremented for each new figure). If num is a string, the figure label and the window title is set to this value. If num is a SubFigure, its parent Figure is activated.
rcParams["figure.figsize"] (default: [6.4, 4.8])
Width, height in inches.
rcParams["figure.dpi"] (default: 100.0)
The resolution of the figure in dots-per-inch.
rcParams["figure.facecolor"] (default: 'white')
The background color.
rcParams["figure.edgecolor"] (default: 'white')
The border color.
If False, suppress drawing the figure frame.
Figure
If set, an instance of this subclass will be created, rather than a plain Figure.
If True and the figure already exists, then it is cleared.
LayoutEngine, None}, default: None
The layout mechanism for positioning of plot elements to avoid overlapping Axes decorations (labels, ticks, etc). Note that layout managers can measurably slow down figure display.
'constrained': The constrained layout solver adjusts Axes sizes to avoid overlapping Axes decorations. Can handle complex plot layouts and colorbars, and is thus recommended.
See Constrained layout guide for examples.
Figure.set_tight_layout for further details.LayoutEngine instance. Builtin layout classes are ConstrainedLayoutEngine and TightLayoutEngine, more easily accessible by 'constrained' and 'tight'. Passing an instance allows third parties to provide their own layout engine.If not given, fall back to using the parameters tight_layout and constrained_layout, including their config defaults rcParams["figure.autolayout"] (default: False) and rcParams["figure.constrained_layout.use"] (default: False).
Additional keyword arguments are passed to the Figure constructor.
A newly created figure is passed to the new_manager method or the new_figure_manager function provided by the current backend, which install a canvas and a manager on the figure.
Once this is done, rcParams["figure.hooks"] (default: []) are called, one at a time, on the figure; these hooks allow arbitrary customization of the figure (e.g., attaching callbacks) or of associated elements (e.g., modifying the toolbar). See mplcvd -- an example of figure hook for an example of toolbar customization.
If you are creating many figures, make sure you explicitly call pyplot.close on the figures you are not using, because this will enable pyplot to properly clean up the memory.
rcParams defines the default values, which can be modified in the matplotlibrc file.
matplotlib.pyplot.figure
Using Gridspec to make multi-column/row subplot layouts
Concatenating text objects with different properties
Plot contour (level) curves in 3D using the extend3d option
3D voxel / volumetric plot with cylindrical coordinates
SkewT-logP diagram: using transforms and custom projections
Complex and semantic figure composition (subplot_mosaic)
© 2012–2023 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.figure.html