Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cffff13

Browse files
authored
Merge pull request #16535 from timhoffm/doc-plt-figure
Clarify docs of num parameter of plt.figure()
2 parents e9a2918 + 44d6e5d commit cffff13

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lib/matplotlib/pyplot.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -449,19 +449,23 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
449449
**kwargs
450450
):
451451
"""
452-
Create a new figure.
452+
Create a new figure, or activate an existing figure.
453453
454454
Parameters
455455
----------
456456
num : int or str, optional
457-
If not provided, a new figure will be created, and the figure number
458-
will be incremented. The figure objects holds this number in a `number`
459-
attribute.
460-
If num is provided, and a figure with this id already exists, make
461-
it active, and returns a reference to it. If this figure does not
462-
exists, create it and returns it.
463-
If num is a string, the window title will be set to this figure's
464-
*num*.
457+
A unique identifier for the figure.
458+
459+
If a figure with that identifier already exists, this figure is made
460+
active and returned. An integer refers to the ``Figure.number``
461+
attribute, a string refers to the figure label.
462+
463+
If there is no figure with the identifier or *num* is not given, a new
464+
figure is created, made active and returned. If *num* is an int, it
465+
will be used for the ``Figure.number`` attribute, otherwise, an
466+
auto-generated integer value is used (starting at 1 and incremented
467+
for each new figure). If *num* is a string, the figure label and the
468+
window title is set to this value.
465469
466470
figsize : (float, float), default: :rc:`figure.figsize`
467471
Width, height in inches.

0 commit comments

Comments
 (0)