- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Flushing all current figures in matplotlib
To flush all current figures in matplotlib, use close('all') method.
Steps
Set the figure size and adjust the padding between and around the subplots.
Create a figure with the title "First Figure".
Create another figure with the title "Second Figure".
To close all figures, use close('all').
To display the figure, use show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.figure("First Figure") plt.figure("Second Figure") # plt.close('all') plt.show()
Output
Notice that we have commented the line −
plt.close('all')
Hence, it will display two figures −
Uncomment the line plt.close('all') and run the code again. It will flush all the current figures.
- Related Articles
- Saving all the open Matplotlib figures in one file at once
- Get the list of figures in Matplotlib
- How can I show figures separately in Matplotlib?
- Drawing multiple figures in parallel in Python with Matplotlib
- How to show two figures using Matplotlib?
- How to customize spines of Matplotlib figures?
- Saving multiple figures to one PDF file in matplotlib
- How to save figures to pdf as raster images in Matplotlib?
- How to manipulate figures while a script is running in Python Matplotlib?
- How to set the current figure in Matplotlib?
- How to view all colormaps available in Matplotlib?
- How to display all label values in Matplotlib?
- What are significant figures?
- Display all records ignoring the current date record in MySQL
- How do you get the current figure number in Python's Matplotlib?

Advertisements