Matplotlib.figure.Figure.clear() in Python Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements. matplotlib.figure.Figure.clear() function The clear() method figure module of matplotlib library is used to Clear the figure. Syntax: clear(self, keep_observers=False) Parameters: This accept the following parameters that are described below: keep_observers: This parameter is the boolean value. Returns: This method does not return any value. Below examples illustrate the matplotlib.figure.Figure.clear() function in matplotlib.figure: Example 1: Python3 # Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.set_xlabel('x-axis') ax.set_ylabel('y-axis') ax.plot([1, 2, 3]) ax.grid(True) fig.clear(True) fig.suptitle('matplotlib.figure.Figure.clear() \ function Example\n\n', fontweight ="bold") plt.show() Output: Example 2: Python3 # Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt t = np.linspace(0.0, 2.0, 201) s = np.sin(2 * np.pi * t) fig, [ax, ax1] = plt.subplots(2, 1, sharex = True) ax.set_ylabel('y-axis') ax.plot(t, s) ax.grid(True) ax.set_title('Sample Example', fontsize = 12, fontweight ='bold') ax1.set_ylabel('y-axis') ax1.plot(t, s) ax1.grid(True) fig.clear(False) fig.suptitle('matplotlib.figure.Figure.clear() \ function Example\n\n', fontweight ="bold") plt.show() Output: Comment More infoAdvertise with us Next Article Company-wise Practice Problems S shubhamsingh10 Follow Improve Article Tags : Python Python-matplotlib Matplotlib figure-class Practice Tags : python Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like