Create a new figure, or activate an existing figure.
Figure
, 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.
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
Optionally use a custom Figure
instance.
If True and the figure already exists, then it is cleared.
rcParams["figure.autolayout"]
(default: False
)
If False
use subplotpars. If True
adjust subplot parameters using tight_layout
with default padding. When providing a dict containing the keys pad
, w_pad
, h_pad
, and rect
, the default tight_layout
paddings will be overridden.
rcParams["figure.constrained_layout.use"]
(default: False
)
If True
use constrained layout to adjust positioning of plot elements. Like tight_layout
, but designed to be more flexible. See Constrained Layout Guide for examples. (Note: does not work with add_subplot
or subplot2grid
.)
See Figure
for other possible arguments.
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
© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.figure.html