Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>They all do different things, since matplotlib uses a hierarchical order in which a figure window contains a figure which may consist of many axes. Additionally, there are functions from the pyplot interface and there are methods on the <code>Figure</code> class. I will discuss both cases below.</p> <h2>pyplot interface</h2> <p><code>pyplot</code> is a module that collects a couple of functions that allow matplotlib to be used in a functional manner. I here assume that <code>pyplot</code> has been imported as <code>import matplotlib.pyplot as plt</code>. In this case, there are three different commands that remove stuff:</p> <p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.cla" rel="noreferrer"><code>plt.cla()</code> clears an axes</a>, i.e. the currently active axes in the current figure. It leaves the other axes untouched.</p> <p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.clf" rel="noreferrer"><code>plt.clf()</code> clears the entire current figure</a> with all its axes, but leaves the window opened, such that it may be reused for other plots.</p> <p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.close" rel="noreferrer"><code>plt.close()</code> closes a window</a>, which will be the current window, if not specified otherwise.</p> <p>Which functions suits you best depends thus on your use-case.</p> <p>The <code>close()</code> function furthermore allows one to specify which window should be closed. The argument can either be a number or name given to a window when it was created using <code>figure(number_or_name)</code> or it can be a figure instance <code>fig</code> obtained, i.e., using<code>fig = figure()</code>. If no argument is given to <code>close()</code>, the currently active window will be closed. Furthermore, there is the syntax <code>close('all')</code>, which closes all figures.</p> <h2>methods of the Figure class</h2> <p>Additionally, the <code>Figure</code> class provides methods for clearing figures. I'll assume in the following that <code>fig</code> is an instance of a <code>Figure</code>:</p> <p><a href="http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.clf" rel="noreferrer"><code>fig.clf()</code> clears the entire figure</a>. This call is equivalent to <code>plt.clf()</code> only if <code>fig</code> is the current figure.</p> <p><code>fig.clear()</code> is a synonym for <code>fig.clf()</code></p> <p>Note that even <code>del fig</code> will not close the associated figure window. As far as I know the only way to close a figure window is using <code>plt.close(fig)</code> as described above.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload