File tree 2 files changed +7
-1
lines changed
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,7 @@ the desired format::
287
287
import matplotlib.pyplot as plt
288
288
plt.plot([1, 2, 3])
289
289
plt.savefig('myfig.png')
290
+ plt.close()
290
291
291
292
.. seealso ::
292
293
Original file line number Diff line number Diff line change @@ -1172,7 +1172,7 @@ def disconnect(cid: int) -> None:
1172
1172
1173
1173
def close (fig : None | int | str | Figure | Literal ["all" ] = None ) -> None :
1174
1174
"""
1175
- Close a figure window.
1175
+ Close a figure window, and unregister it from pyplot .
1176
1176
1177
1177
Parameters
1178
1178
----------
@@ -1185,6 +1185,11 @@ def close(fig: None | int | str | Figure | Literal["all"] = None) -> None:
1185
1185
- ``str``: a figure name
1186
1186
- 'all': all figures
1187
1187
1188
+ Note
1189
+ ----
1190
+ pyplot maintains a reference to figures created with `figure()` until they
1191
+ are `close()`\ d. Closing figures is thus necessary to prevent running out
1192
+ of memory (see also :rc:`figure.max_open_warning`).
1188
1193
"""
1189
1194
if fig is None :
1190
1195
manager = _pylab_helpers .Gcf .get_active ()
You can’t perform that action at this time.
0 commit comments