From c279201271aad8f8d00294a526d38f60063e58b5 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 24 Mar 2020 11:30:59 -0400 Subject: [PATCH 1/2] add an annotate_list method --- doc/source/visualizing/callbacks.rst | 23 ++++++++++++++++++++++- yt/visualization/plot_window.py | 9 +++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/doc/source/visualizing/callbacks.rst b/doc/source/visualizing/callbacks.rst index 4131c54b4a4..bc8dbfd4b1c 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:: annotate_list() + + 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.annotate_list() + .. _annotate-arrow: Overplot Arrow diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index 8cb1a6203a1..355809bcbe7 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 annotate_list(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() From 1bd7177920b398f32e1ffcc2f1bdbaa828b9c5f2 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Sun, 26 Apr 2020 12:49:27 -0400 Subject: [PATCH 2/2] annotate_list -> list_annotations --- doc/source/visualizing/callbacks.rst | 4 ++-- yt/visualization/plot_window.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/visualizing/callbacks.rst b/doc/source/visualizing/callbacks.rst index bc8dbfd4b1c..6d993bde6ab 100644 --- a/doc/source/visualizing/callbacks.rst +++ b/doc/source/visualizing/callbacks.rst @@ -120,7 +120,7 @@ Clear Callbacks (Some or All) List Currently Applied Callbacks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. function:: annotate_list() +.. 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 @@ -134,7 +134,7 @@ List Currently Applied Callbacks p = yt.SlicePlot(ds, 'z', 'density', center='c', width=(20, 'kpc')) p.annotate_scale() p.annotate_timestamp() - p.annotate_list() + p.list_annotations() .. _annotate-arrow: diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py index 355809bcbe7..3ddaedb1e48 100644 --- a/yt/visualization/plot_window.py +++ b/yt/visualization/plot_window.py @@ -1119,7 +1119,7 @@ def annotate_clear(self, index=None): self.setup_callbacks() return self - def annotate_list(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