 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I close all the open pyplot windows (Matplotlib)?
plt.figure().close(): Close a figure window.
close() by itself closes the current figure
close(h), where h is a Figure instance, closes that figure
close(num) closes the figure with number=num
close(name), where name is a string, closes the figure with that label
close('all') closes all the figure windows
Example
from matplotlib import pyplot as plt fig = plt.figure() ax = fig.add_subplot() plt.show() plt.close()
Output

Now, swap the statements "plt.show()" and "plt.close()" in the code. You wouldn't get to see any plot as the output because the plot would already have been closed.
Advertisements
 