Create a new figure, or activate an existing figure. Parameters ---------- num : int or str or `.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.
(
# autoincrement if None, else integer from 1-N
num: int | str | Figure | SubFigure | None = None,
# defaults to rc figure.figsize
figsize: ArrayLike # a 2-element ndarray is accepted as well
| tuple[float, float, Literal["in", "cm", "px"]]
| None = None,
# defaults to rc figure.dpi
dpi: float | None = None,
*,
# defaults to rc figure.facecolor
facecolor: ColorType | None = None,
# defaults to rc figure.edgecolor
edgecolor: ColorType | None = None,
frameon: bool = True,
FigureClass: type[Figure] = Figure,
clear: bool = False,
**kwargs
)
| 901 | ## Figures ## |
| 902 | |
| 903 | def figure( |
| 904 | # autoincrement if None, else integer from 1-N |
| 905 | num: int | str | Figure | SubFigure | None = None, |
| 906 | # defaults to rc figure.figsize |
| 907 | figsize: ArrayLike # a 2-element ndarray is accepted as well |
| 908 | | tuple[float, float, Literal["in", "cm", "px"]] |
| 909 | | None = None, |
| 910 | # defaults to rc figure.dpi |
| 911 | dpi: float | None = None, |
| 912 | *, |
| 913 | # defaults to rc figure.facecolor |
| 914 | facecolor: ColorType | None = None, |
| 915 | # defaults to rc figure.edgecolor |
| 916 | edgecolor: ColorType | None = None, |
| 917 | frameon: bool = True, |
| 918 | FigureClass: type[Figure] = Figure, |
| 919 | clear: bool = False, |
| 920 | **kwargs |
| 921 | ) -> Figure: |
| 922 | """ |
| 923 | Create a new figure, or activate an existing figure. |
| 924 | |
| 925 | Parameters |
| 926 | ---------- |
| 927 | num : int or str or `.Figure` or `.SubFigure`, optional |
| 928 | A unique identifier for the figure. |
| 929 | |
| 930 | If a figure with that identifier already exists, this figure is made |
| 931 | active and returned. An integer refers to the ``Figure.number`` |
| 932 | attribute, a string refers to the figure label. |
| 933 | |
| 934 | If there is no figure with the identifier or *num* is not given, a new |
| 935 | figure is created, made active and returned. If *num* is an int, it |
| 936 | will be used for the ``Figure.number`` attribute, otherwise, an |
| 937 | auto-generated integer value is used (starting at 1 and incremented |
| 938 | for each new figure). If *num* is a string, the figure label and the |
| 939 | window title is set to this value. If num is a ``SubFigure``, its |
| 940 | parent ``Figure`` is activated. |
| 941 | |
| 942 | If *num* is a Figure instance that is already tracked in pyplot, it is |
| 943 | activated. If *num* is a Figure instance that is not tracked in pyplot, |
| 944 | it is added to the tracked figures and activated. |
| 945 | |
| 946 | figsize : (float, float) or (float, float, str), default: :rc:`figure.figsize` |
| 947 | The figure dimensions. This can be |
| 948 | |
| 949 | - a tuple ``(width, height, unit)``, where *unit* is one of "inch", "cm", |
| 950 | "px". |
| 951 | - a tuple ``(x, y)``, which is interpreted as ``(x, y, "inch")``. |
| 952 | |
| 953 | One of *width* or *height* may be ``None``; the respective value is taken |
| 954 | from :rc:`figure.figsize`. |
| 955 | |
| 956 | dpi : float, default: :rc:`figure.dpi` |
| 957 | The resolution of the figure in dots-per-inch. |
| 958 | |
| 959 | facecolor : :mpltype:`color`, default: :rc:`figure.facecolor` |
| 960 | The background color. |
no test coverage detected
searching dependent graphs…