Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc5bd424

Browse files
committed
Improve docs regarding plt.close().
1 parentdc05767 commitc5bd424

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

‎doc/users/faq.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ the desired format::
287287
import matplotlib.pyplot as plt
288288
plt.plot([1, 2, 3])
289289
plt.savefig('myfig.png')
290+
plt.close()
290291

291292
..seealso::
292293

‎lib/matplotlib/pyplot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,8 @@ def disconnect(cid: int) -> None:
11711171

11721172

11731173
defclose(fig:None|int|str|Figure|Literal["all"]=None)->None:
1174-
"""
1175-
Close a figure window.
1174+
r"""
1175+
Close a figure window, and unregister it from pyplot.
11761176
11771177
Parameters
11781178
----------
@@ -1185,6 +1185,11 @@ def close(fig: None | int | str | Figure | Literal["all"] = None) -> None:
11851185
- ``str``: a figure name
11861186
- 'all': all figures
11871187
1188+
Notes
1189+
-----
1190+
pyplot maintains a reference to figures created with `figure()` until
1191+
`close()` is called on them. Closing figures is thus necessary to prevent
1192+
running out of memory (see also :rc:`figure.max_open_warning`).
11881193
"""
11891194
iffigisNone:
11901195
manager=_pylab_helpers.Gcf.get_active()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp