{"id":6448,"date":"2020-12-18T08:45:35","date_gmt":"2020-12-18T03:15:35","guid":{"rendered":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/?p=6448"},"modified":"2023-12-31T17:53:10","modified_gmt":"2023-12-31T12:23:10","slug":"clear-plot-matplotlib","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/","title":{"rendered":"How to Clear Plot in Matplotlib Using clear() Method"},"content":{"rendered":"\n<p>Hello programmers, in today&#8217;s article, we will discuss Matplotlib clear plot in python. Matplotlib&nbsp;is a library in Python, which is a numerical \u2013 mathematical extension for NumPy library. The&nbsp;figure module of the Matplotlib library&nbsp;provides the top-level Artist, the Figure, which contains all the plot elements. The figure module is used to control the subplots&#8217; default spacing and top-level container for all plot elements.<\/p>\n\n\n\n<p>The&nbsp;Axes Class&nbsp;contains the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. The instances of Axes supports callbacks through a callbacks attribute. The&nbsp;Axes.clear() in the axes module of the matplotlib library is used to clear the axes. Thus, the Matplotlib figure.clear() and axes.clear() is used to clear figure and axes, respectively. Here are the syntax and parameters of the Matplotlib clear plot function.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#Syntax_of_Matplotlib_clear_plot_in_Python\" title=\"Syntax of Matplotlib clear plot in Python\">Syntax of Matplotlib clear plot in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#Parameter\" title=\"Parameter \">Parameter <\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#Return_type\" title=\"Return type\">Return type<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#Example_of_Matplotlib_Figure_clear_plot\" title=\"Example of Matplotlib Figure clear plot\">Example of Matplotlib Figure clear plot<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#Example_of_Matplotlib_Axis_clear_plot\" title=\"Example of Matplotlib Axis clear plot\">Example of Matplotlib Axis clear plot<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#Must_Read\" title=\"Must Read\">Must Read<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-syntax-of-matplotlib-clear-plot-in-python\"><span class=\"ez-toc-section\" id=\"Syntax_of_Matplotlib_clear_plot_in_Python\"><\/span>Syntax of Matplotlib clear plot in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>clear(self, keep_observers=False)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-parameter\"><span class=\"ez-toc-section\" id=\"Parameter\"><\/span><strong>Parameter<\/strong> <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The axis.clear() function accepts no parameters. <br>The &#8216;keep_observers&#8217; parameter in figure.clear() function is a boolean value.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-return-type\"><span class=\"ez-toc-section\" id=\"Return_type\"><\/span>Return type<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The clear() function does not return any value. It is used in python programs to clear plots.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-example-of-matplotlib-figure-clear-plot\"><span class=\"ez-toc-section\" id=\"Example_of_Matplotlib_Figure_clear_plot\"><\/span>Example of Matplotlib Figure clear plot<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np \nimport matplotlib.pyplot as plt \n      \nfig, ax = plt.subplots() \n  \nax.set_xlabel('x-axis') \nax.set_ylabel('y-axis') \n  \nax.plot(&#x5B;1, 2, 3]) \nax.grid(True) \n  \nfig.clear(True) \n   \nfig.suptitle('matplotlib.figure.Figure.clear() \\ \nfunction Example\\n\\n', fontweight =&quot;bold&quot;) \n  \nplt.show() \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" width=\"542\" height=\"403\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-71.png\" alt=\"Matplotlib clear figure plot in Python\" class=\"wp-image-6449\" style=\"aspect-ratio:1.3460207612456747;width:332px;height:auto\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-71.png 542w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-71-300x223.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-71-150x112.png 150w\" sizes=\"(max-width: 542px) 100vw, 542px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>In the above example, we first create a plot per input data values. The xlabel is &#8216;x-axis,&#8217; and the ylabel is &#8216;y-axis.&#8217; The title of the figure is &#8216;matplotlib.figure.Figure.clear() function Example&#8217;. The gridlines are also plotted for the figure by setting ax.grid(True).  But before the plt.show() statement that shows the plotted figure, we use the fig.clear() function. The fig.clear() <a href=\"https:\/\/en.wikipedia.org\/wiki\/Function\" target=\"_blank\" rel=\"noreferrer noopener\">function<\/a> clears the figure plot when &#8216;True&#8217; is an argument. Thus, in this example, since fig.clear(True) is before the plt.show(), the output is the entire clear current figure except the figure title.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-example-of-matplotlib-axis-clear-plot\"><span class=\"ez-toc-section\" id=\"Example_of_Matplotlib_Axis_clear_plot\"><\/span>Example of Matplotlib Axis clear plot<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np \nimport matplotlib.pyplot as plt \n     \nt = np.linspace(0.0, 2.0, 201) \ns = np.sin(2 * np.pi * t) \n  \nfig, &#x5B;ax, ax1] = plt.subplots(2, 1, sharex = True) \n  \nax.set_ylabel('y-axis') \nax.plot(t, s) \nax.grid(True) \nax.set_title('matplotlib.axes.Axes.clear() Example\\n\\n Sample Example', \n             fontsize = 12, fontweight ='bold') \n  \nax1.set_ylabel('y-axis') \nax1.plot(t, s) \nax1.grid(True) \nax1.clear() \nax1.set_title('Above example with clear() \\ \nfunction', fontsize = 12, fontweight ='bold') \nplt.show() \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" width=\"581\" height=\"471\" src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-72.png\" alt=\"Matplotlib Axes clear plot in python\" class=\"wp-image-6450\" style=\"width:506px;height:410px\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-72.png 581w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-72-300x243.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-72-150x122.png 150w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation-1\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>In the above example, the two plots &#8216;ax&#8217; and &#8216;ax1&#8217; are created. The ylabel of figure 1 is &#8216;y-axis.&#8217; The Matplotlib grid() is also &#8216;True,&#8217; which returns grid lines for the figure. Also, the title of the figure is mentioned. But, we do not use the Matplotlib clear() function with the &#8216;ax&#8217; plot. For the second figure, we <a href=\"https:\/\/www.pythonpool.com\/scree-plot-python\/\" target=\"_blank\" rel=\"noopener\">plot<\/a> it as per the given input values. But since the ax2.clear() is used, the current &#8216;ax2&#8217; figure plot is cleared except for its title. Finally, the plt.show() statement gives the &#8216;ax&#8217; figure and clears the &#8216;ax2&#8217; figure with just its title.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-vivid-red-color has-text-color\" id=\"h-must-read\"><span class=\"ez-toc-section\" id=\"Must_Read\"><\/span>Must Read<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul>\n<li><a href=\"https:\/\/www.pythonpool.com\/how-to-clear-python-shell\/\" rel=\"noreferrer noopener\" target=\"_blank\">How to Clear Python Shell in the Most Effective Way<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.pythonpool.com\/matplotlib-savefig\/\" rel=\"noreferrer noopener\" target=\"_blank\">Matplotlib Savefig() For Different Parameters in Python<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.pythonpool.com\/numpy-axis\/\" rel=\"noreferrer noopener\" target=\"_blank\">Numpy Axis in Python With Detailed Examples<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have discussed ways of Matplotlib clear plot in Python. The clear() function as axes.clear() or figure.clear() clears the axes and figure of the plot, respectively. We have discussed both axes clearly and figure clear with examples and explanations. The Matplotlib cla() function can be used as axes.clear() function. Similarly, the clf() function makes figure clear. Both cla() and clf() clears plot in Matplotlib.<\/p>\n\n\n\n<p>However, if you have any doubts or questions, do let me know in the comment section below. I will try to help you as soon as possible.<\/p>\n\n\n\n<p><strong><em>Happy Pythoning!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello programmers, in today&#8217;s article, we will discuss Matplotlib clear plot in python. Matplotlib&nbsp;is a library in Python, which is a numerical \u2013 mathematical extension &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Clear Plot in Matplotlib Using clear() Method\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#more-6448\" aria-label=\"More on How to Clear Plot in Matplotlib Using clear() Method\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":6589,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2071],"tags":[2874,2871,2873,2872,2875,2876],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v22.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Clear Plot in Matplotlib Using clear() Method - Python Pool<\/title>\n<meta name=\"description\" content=\"Examples of Matplotlib clear plot in Python using axes.clear() and figure.clear() which clears current axes and figure, respectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Clear Plot in Matplotlib Using clear() Method\" \/>\n<meta property=\"og:description\" content=\"Hello programmers, in today&#039;s article, we will discuss Matplotlib clear plot in python. Matplotlib&nbsp;is a library in Python, which is a numerical \u2013\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-18T03:15:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-31T12:23:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Python Pool\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Python Pool\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/\"},\"author\":{\"name\":\"Python Pool\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998\"},\"headline\":\"How to Clear Plot in Matplotlib Using clear() Method\",\"datePublished\":\"2020-12-18T03:15:35+00:00\",\"dateModified\":\"2023-12-31T12:23:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/\"},\"wordCount\":552,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png\",\"keywords\":[\"clear plot matplotlib\",\"clear points scatter plot matplotlib\",\"matplotlib plot clear\",\"plot clear matplotlib\",\"python matplotlib clear plot\",\"python matplotlib plot clear\"],\"articleSection\":[\"Matplotlib\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/\",\"url\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/\",\"name\":\"How to Clear Plot in Matplotlib Using clear() Method - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png\",\"datePublished\":\"2020-12-18T03:15:35+00:00\",\"dateModified\":\"2023-12-31T12:23:10+00:00\",\"description\":\"Examples of Matplotlib clear plot in Python using axes.clear() and figure.clear() which clears current axes and figure, respectively.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png\",\"width\":1350,\"height\":650,\"caption\":\"clear plot matplotlib\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Clear Plot in Matplotlib Using clear() Method\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998\",\"name\":\"Python Pool\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g\",\"caption\":\"Python Pool\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Clear Plot in Matplotlib Using clear() Method - Python Pool","description":"Examples of Matplotlib clear plot in Python using axes.clear() and figure.clear() which clears current axes and figure, respectively.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/","og_locale":"en_US","og_type":"article","og_title":"How to Clear Plot in Matplotlib Using clear() Method","og_description":"Hello programmers, in today's article, we will discuss Matplotlib clear plot in python. Matplotlib&nbsp;is a library in Python, which is a numerical \u2013","og_url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/","og_site_name":"Python Pool","article_published_time":"2020-12-18T03:15:35+00:00","article_modified_time":"2023-12-31T12:23:10+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png","type":"image\/png"}],"author":"Python Pool","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Python Pool","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/"},"author":{"name":"Python Pool","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998"},"headline":"How to Clear Plot in Matplotlib Using clear() Method","datePublished":"2020-12-18T03:15:35+00:00","dateModified":"2023-12-31T12:23:10+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/"},"wordCount":552,"commentCount":0,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png","keywords":["clear plot matplotlib","clear points scatter plot matplotlib","matplotlib plot clear","plot clear matplotlib","python matplotlib clear plot","python matplotlib plot clear"],"articleSection":["Matplotlib"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/","url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/","name":"How to Clear Plot in Matplotlib Using clear() Method - Python Pool","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png","datePublished":"2020-12-18T03:15:35+00:00","dateModified":"2023-12-31T12:23:10+00:00","description":"Examples of Matplotlib clear plot in Python using axes.clear() and figure.clear() which clears current axes and figure, respectively.","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-32.png","width":1350,"height":650,"caption":"clear plot matplotlib"},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/clear-plot-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"How to Clear Plot in Matplotlib Using clear() Method"}]},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/twitter.com\/pythonpool","https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998","name":"Python Pool","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g","caption":"Python Pool"}}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6448"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=6448"}],"version-history":[{"count":11,"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6448\/revisions"}],"predecessor-version":[{"id":31410,"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6448\/revisions\/31410"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/6589"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=6448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=6448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=6448"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20240926033952\/https:\/\/api.w.org\/{rel}","templated":true}]}}