matplotlib.pyplot.close
- matplotlib.pyplot.close(fig=None)[source]
-
Close a figure window, and unregister it from pyplot.
- Parameters:
Notes
pyplot maintains a reference to figures created with
figure(). When work on the figure is completed, it should be closed, i.e. deregistered from pyplot, to free its memory (see also :rc:figure.max_open_warning). Closing a figure window created byshow()automatically deregisters the figure. For all other use cases, most prominentlysavefig()withoutshow(), the figure must be deregistered explicitly usingclose().
Examples using matplotlib.pyplot.close
© 2012–2026 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.close.html