diff --git a/doc/source/visualizing/callbacks.rst b/doc/source/visualizing/callbacks.rst index 4131c54b4a4..6d993bde6ab 100644 --- a/doc/source/visualizing/callbacks.rst +++ b/doc/source/visualizing/callbacks.rst @@ -93,7 +93,7 @@ The underlying functions are more thoroughly documented in :ref:`callback-api`. .. _annotate-clear: Clear Callbacks (Some or All) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. function:: annotate_clear(index=None) @@ -115,6 +115,27 @@ Clear Callbacks (Some or All) p.annotate_clear() p.save() +.. _annotate-list: + +List Currently Applied Callbacks +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. function:: list_annotations() + + This function will print a list of each of the currently applied + callbacks together with their index. The index can be used with + :ref:`annotate_clear() function ` to remove a + specific callback. + +.. python-script:: + + import yt + ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") + p = yt.SlicePlot(ds, 'z', 'density', center='c', width=(20, 'kpc')) + p.annotate_scale() + p.annotate_timestamp() + p.list_annotations() + .. _annotate-arrow: Overplot Arrow diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index 8cb1a6203a1..3ddaedb1e48 100644 --- a/yt/visualization/plot_window.py +++ b/yt/visualization/plot_window.py @@ -1119,6 +1119,15 @@ def annotate_clear(self, index=None): self.setup_callbacks() return self + def list_annotations(self): + """ + List the current callbacks for the plot, along with their index. This + index can be used with annotate_clear to remove a callback from the + current plot. + """ + for i, cb in enumerate(self._callbacks): + print(i, cb) + def run_callbacks(self): for f in self.fields: keys = self.frb.keys()