Clear ===== | A plot accumulates signals, settings, :ref:`pixels `, styles and a possibly nested grid of :ref:`subplots ` over its lifetime. | The clear methods take all of that, or just **one slice** of it, back to the defaults. | They are grouped under the :class:`clear ` attribute of the figure, and of any :ref:`subplot `. Clear Everything ---------------- Calling the attribute itself as a method, as in ``plotext.figure.clear()``, resets the plot to an **empty state**: signals, settings, :ref:`pixels `, styles and sizes all return to their defaults in one call. .. code-block:: python import plotext as plt fig = plt.figure fig.clear() The :meth:`plotext.figure.clear.all() ` method does the same, the call form being a shortcut for it. Granular Clears --------------- Each granular method touches one slice of the plot state and leaves the rest untouched. - :meth:`plotext.figure.clear.data() `: drops the plotted data: every signal added via ``draw()``, the lines placed by the :meth:`line() ` and :meth:`event() ` methods, and their :ref:`legend ` entries; the color :ref:`cycler ` resets, every color available again. Settings, :ref:`pixels `, styles and sizes are *preserved*, ready for new data on the same configured plot. - :meth:`plotext.figure.clear.settings() `: resets the plot settings back to defaults: the title, the :doc:`axis ` labels, the limits, the :ref:`numerical ticks ` and their frequency, the scale, the alignments, the direction, the :doc:`date ` support, the :ref:`grid `, the frame visibility, and the :ref:`legend ` visibility, position and alignment. Signals, :ref:`pixels `, styles and sizes are *preserved*. - :meth:`plotext.figure.clear.size() `: drops any explicit :meth:`plot_size() ` value and resets every :ref:`subplot ` size, so the next :meth:`plot_size() ` call redistributes the space proportionally. On the master, the :doc:`terminal ` size is read again, in case the window was resized. Signals, :ref:`subplots `, settings, :ref:`pixels `, styles and the terminal own settings are *preserved*. - :meth:`plotext.figure.clear.subplots() `: wipes the :ref:`subplots ` grid configured on this plot, returning to a single panel layout. Signals, settings, :ref:`pixels `, styles and size are *preserved*. - :meth:`plotext.figure.clear.pixels() `: resets every :ref:`pixel ` on the plot (labels, :doc:`rulers `, :doc:`axes `, legend and the :doc:`canvas ` itself) to the package defaults, and rewinds the color cycler. Signals, settings, styles and sizes are *preserved*. - :meth:`plotext.figure.clear.styles() `: resets the line styles of the :doc:`axes ` and of the :ref:`grid ` lines to *default*. Signals, settings, :ref:`pixels ` and sizes are *preserved*. .. note:: Calling :meth:`plotext.figure.clear.pixels() ` is equivalent to applying the *default* :doc:`theme `: both take every color on the plot back to its package default. Cascading --------- | Every clear method cascades through the :ref:`subplots ` of the plot it is called on: a single :meth:`plotext.figure.clear.settings() ` on the master figure resets the settings on the master and on every nested subplot. | The same holds at any depth: called on a subplot that holds its own subplots, the method clears that whole branch, leaving the rest of the plot untouched. | To clear a single :ref:`subplot `, address it first, as in :meth:`plotext.figure.subplot(2, 1).clear.settings() `. .. seealso:: The :doc:`terminal ` object holds its own pair of resets, :meth:`clean() ` and :meth:`clear() `, described in the :ref:`terminal clearing ` section of its page.