Repository: yt-project/yt

Issue:
PhasePlot is missing [show,hide]_axes() and [show,hide]_colorbar()
Currently the `PlotWindow` plots all have `show_axes`, `hide_axes`, `show_colorbar`, and `hide_colorbar` implemented. Since the actual functionality for hiding and displaying the colorbar is handled by the lower-level matplotlib wrapper objects (e.g. `PlotMPL`, `WindowPlotMPL`, and `PhasePlotMPL`) the implementations of these functions on the `PlotWindow` class are pretty simple:

https://github.com/yt-project/yt/blob/51cf1ce0825dd1e9ef6bbbf8e9a83a82a768cd7e/yt/visualization/plot_window.py#L1046-L1051

For example, I've pasted the implementation of `hide_colorbar` above.

As pointed out by Stephannie Tonneson on the mailing list, currently the `PhasePlot` object does not have these methods. This is a bit of an API inconsistency. I think it should be possible to move these methods to the base `PlotContainer` class or barring that, add separate implementations for these function on the `PhasePlot` class itself. This should be simple since the underlying `PhasePlotMPL` class already can handle hiding the axes and colorbar:

```python
plot = yt.PhasePlot(ds.all_data(), 'density', 'temperature', 'cell_mass')
p = plot.plots['cell_mass']
p.hide_colorbar()
plot.save()
```


Discussion:
Can I work on this?
Please :)

In general you don't need to ask whether you want to work on something you can just do it, unless someone has already recently indicated on the issue that they're actively working on it.
Ok thanks! 
@cldssty seems to be inactive on this issue.
Can I take it?
Please feel free. Let me know if my initial description isn't enough for you to get started. I'd also encourage you to look at our developer guide: http://yt-project.org/doc/developing/index.html

Resolving patch:
diff --git a/yt/visualization/plot_container.py b/yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -651,6 +651,139 @@ def _get_axes_unit_labels(self, unit_x, unit_y):
                 axes_unit_labels[i] = '\ \ ('+un+')'
         return axes_unit_labels
 
+    
+    def hide_colorbar(self, field=None):
+        """
+        Hides the colorbar for a plot and updates the size of the
+        plot accordingly.  Defaults to operating on all fields for a
+        PlotContainer object.
+
+        Parameters
+        ----------
+
+        field : string, field tuple, or list of strings or field tuples (optional)
+            The name of the field(s) that we want to hide the colorbar. If None
+            is provided, will default to using all fields available for this
+            object.
+
+        Examples
+        --------
+
+        This will save an image with no colorbar.
+
+        >>> import yt
+        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
+        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
+        >>> s.hide_colorbar()
+        >>> s.save()
+
+        This will save an image with no axis or colorbar.
+
+        >>> import yt
+        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
+        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
+        >>> s.hide_axes()
+        >>> s.hide_colorbar()
+        >>> s.save()
+        """
+        if field is None:
+            field = self.fields
+        field = ensure_list(field)
+        for f in field:
+            self.plots[f].hide_colorbar()
+        return self
+
+
+    def show_colorbar(self, field=None):
+        """
+        Shows the colorbar for a plot and updates the size of the
+        plot accordingly.  Defaults to operating on all fields for a
+        PlotContainer object.  See hide_colorbar().
+
+        Parameters
+        ----------
+
+        field : string, field tuple, or list of strings or field tuples (optional)
+        The name of the field(s) that we want to show the colorbar.
+        """
+        if field is None:
+            field = self.fields
+        field = ensure_list(field)
+        for f in field:
+            self.plots[f].show_colorbar()
+        return self
+
+    def hide_axes(self, field=None, draw_frame=False):
+        """
+        Hides the axes for a plot and updates the size of the
+        plot accordingly.  Defaults to operating on all fields for a
+        PlotContainer object.
+
+        Parameters
+        ----------
+
+        field : string, field tuple, or list of strings or field tuples (optional)
+            The name of the field(s) that we want to hide the axes.
+
+        draw_frame : boolean
+            If True, the axes frame will still be drawn. Defaults to False.
+            See note below for more details.
+
+        Examples
+        --------
+
+        This will save an image with no axes.
+
+        >>> import yt
+        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
+        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
+        >>> s.hide_axes()
+        >>> s.save()
+
+        This will save an image with no axis or colorbar.
+
+        >>> import yt
+        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
+        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
+        >>> s.hide_axes()
+        >>> s.hide_colorbar()
+        >>> s.save()
+
+        Note
+        ----
+        By default, when removing the axes, the patch on which the axes are
+        drawn is disabled, making it impossible to later change e.g. the
+        background colour. To force the axes patch to be displayed while still
+        hiding the axes, set the ``draw_frame`` keyword argument to ``True``.
+        """
+        if field is None:
+            field = self.fields
+        field = ensure_list(field)
+        for f in field:
+            self.plots[f].hide_axes(draw_frame)
+        return self
+
+
+    def show_axes(self, field=None):
+        """
+        Shows the axes for a plot and updates the size of the
+        plot accordingly.  Defaults to operating on all fields for a
+        PlotContainer object.  See hide_axes().
+
+        Parameters
+        ----------
+
+        field : string, field tuple, or list of strings or field tuples (optional)
+            The name of the field(s) that we want to show the axes.
+        """
+        if field is None:
+            field = self.fields
+        field = ensure_list(field)
+        for f in field:
+            self.plots[f].show_axes()
+        return self
+
+
 
 class ImagePlotContainer(PlotContainer):
     """A container for plots with colorbars.
diff --git a/yt/visualization/plot_window.py b/yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1129,134 +1129,7 @@ def run_callbacks(self):
                 if key not in keys:
                     del self.frb[key]
 
-    def hide_colorbar(self, field=None):
-        """
-        Hides the colorbar for a plot and updates the size of the
-        plot accordingly.  Defaults to operating on all fields for a
-        PlotWindow object.
-
-        Parameters
-        ----------
-
-        field : string, field tuple, or list of strings or field tuples (optional)
-            The name of the field(s) that we want to hide the colorbar. If None
-            is provided, will default to using all fields available for this
-            object.
-
-        Examples
-        --------
-
-        This will save an image with no colorbar.
-
-        >>> import yt
-        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
-        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
-        >>> s.hide_colorbar()
-        >>> s.save()
 
-        This will save an image with no axis or colorbar.
-
-        >>> import yt
-        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
-        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
-        >>> s.hide_axes()
-        >>> s.hide_colorbar()
-        >>> s.save()
-        """
-        if field is None:
-            field = self.fields
-        field = ensure_list(field)
-        for f in field:
-            self.plots[f].hide_colorbar()
-        return self
-
-    def show_colorbar(self, field=None):
-        """
-        Shows the colorbar for a plot and updates the size of the
-        plot accordingly.  Defaults to operating on all fields for a
-        PlotWindow object.  See hide_colorbar().
-
-        Parameters
-        ----------
-
-        field : string, field tuple, or list of strings or field tuples (optional)
-            The name of the field(s) that we want to show the colorbar.
-        """
-        if field is None:
-            field = self.fields
-        field = ensure_list(field)
-        for f in field:
-            self.plots[f].show_colorbar()
-        return self
-
-    def hide_axes(self, field=None, draw_frame=False):
-        """
-        Hides the axes for a plot and updates the size of the
-        plot accordingly.  Defaults to operating on all fields for a
-        PlotWindow object.
-
-        Parameters
-        ----------
-
-        field : string, field tuple, or list of strings or field tuples (optional)
-            The name of the field(s) that we want to hide the axes.
-
-        draw_frame : boolean
-            If True, the axes frame will still be drawn. Defaults to False.
-            See note below for more details.
-
-        Examples
-        --------
-
-        This will save an image with no axes.
-
-        >>> import yt
-        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
-        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
-        >>> s.hide_axes()
-        >>> s.save()
-
-        This will save an image with no axis or colorbar.
-
-        >>> import yt
-        >>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
-        >>> s = SlicePlot(ds, 2, 'density', 'c', (20, 'kpc'))
-        >>> s.hide_axes()
-        >>> s.hide_colorbar()
-        >>> s.save()
-
-        Note
-        ----
-        By default, when removing the axes, the patch on which the axes are
-        drawn is disabled, making it impossible to later change e.g. the
-        background colour. To force the axes patch to be displayed while still
-        hiding the axes, set the ``draw_frame`` keyword argument to ``True``.
-        """
-        if field is None:
-            field = self.fields
-        field = ensure_list(field)
-        for f in field:
-            self.plots[f].hide_axes(draw_frame)
-        return self
-
-    def show_axes(self, field=None):
-        """
-        Shows the axes for a plot and updates the size of the
-        plot accordingly.  Defaults to operating on all fields for a
-        PlotWindow object.  See hide_axes().
-
-        Parameters
-        ----------
-
-        field : string, field tuple, or list of strings or field tuples (optional)
-            The name of the field(s) that we want to show the axes.
-        """
-        if field is None:
-            field = self.fields
-        field = ensure_list(field)
-        for f in field:
-            self.plots[f].show_axes()
-        return self
 
 class AxisAlignedSlicePlot(PWViewerMPL):
     r"""Creates a slice plot from a dataset
diff --git a/yt/visualization/profile_plotter.py b/yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -1019,6 +1019,10 @@ def profile(self):
             self._recreate_profile()
         return self._profile
 
+    @property
+    def fields(self):
+        return list(self.plots.keys())
+
     def _setup_plots(self):
         if self._plot_valid:
             return


Test patch:
diff --git a/yt/visualization/tests/test_profile_plots.py b/yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -262,3 +262,36 @@ def test_phaseplot_set_log():
     p2.set_log(ds.fields.gas.temperature, False)
     assert p1.y_log["gas", "density"] is False
     assert p2.y_log is False
+
+
+
+def test_phaseplot_showhide_colorbar_axes():
+    fields = ('density', 'temperature')
+    units = ('g/cm**3', 'K',)
+    ds = fake_random_ds(16, fields=fields, units=units)
+    ad = ds.all_data()
+    plot = yt.PhasePlot(ad, ("gas", "density"), ("gas", "temperature"), "cell_mass")
+
+    # make sure we can hide colorbar
+    plot.hide_colorbar()
+    with tempfile.NamedTemporaryFile(suffix='png') as f1:
+        plot.save(f1.name)
+
+    # make sure we can show colorbar
+    plot.show_colorbar()
+    with tempfile.NamedTemporaryFile(suffix='png') as f2:
+        plot.save(f2.name)
+
+    # make sure we can hide axes
+    plot.hide_axes()
+    with tempfile.NamedTemporaryFile(suffix='png') as f3:
+        plot.save(f3.name)
+
+    # make sure we can show axes
+    plot.show_axes()
+    with tempfile.NamedTemporaryFile(suffix='png') as f4:
+        plot.save(f4.name)
+
+
+
+