Repository: sunpy/sunpy

Issue:
Add an annotate=False kwarg to map.draw_grid
This would disable the axes labels and the ticks on the top and right axes.

For example: http://docs.sunpy.org/en/latest/generated/gallery/map/submaps_and_cropping.html#sphx-glr-generated-gallery-map-submaps-and-cropping-py

In the submap, you have the top and right axes which correspond to the grid and we would like to turn that off. 


Discussion:
Is this still open?
Yes. There is an old WIP PR. 
@gowthamraj198 are you still working on this? Or may I give this a shot?
@Raahul-Singh please work on it. If possible try to work on top of my commits.

Resolving patch:
diff --git a/sunpy/map/mapbase.py b/sunpy/map/mapbase.py
--- a/sunpy/map/mapbase.py
+++ b/sunpy/map/mapbase.py
@@ -1454,7 +1454,7 @@ def cmap(self):
         return cmap
 
     @u.quantity_input
-    def draw_grid(self, axes=None, grid_spacing: u.deg = 15*u.deg, **kwargs):
+    def draw_grid(self, axes=None, grid_spacing: u.deg = 15*u.deg, annotate=True, **kwargs):
         """
         Draws a coordinate overlay on the plot in the Heliographic Stonyhurst
         coordinate system.
@@ -1471,6 +1471,9 @@ def draw_grid(self, axes=None, grid_spacing: u.deg = 15*u.deg, **kwargs):
             Spacing for longitude and latitude grid, if length two it specifies
             (lon, lat) spacing.
 
+        annotate : `bool`
+            Passing `False` disables the axes labels and the ticks on the top and right axes.
+
         Returns
         -------
         overlay: `~astropy.visualization.wcsaxes.coordinates_map.CoordinatesMap`
@@ -1487,6 +1490,7 @@ def draw_grid(self, axes=None, grid_spacing: u.deg = 15*u.deg, **kwargs):
             raise TypeError("Overlay grids can only be plotted on WCSAxes plots.")
         return wcsaxes_compat.wcsaxes_heliographic_overlay(axes,
                                                            grid_spacing=grid_spacing,
+                                                           annotate=annotate,
                                                            **kwargs)
 
     def draw_limb(self, axes=None, **kwargs):
diff --git a/sunpy/visualization/wcsaxes_compat.py b/sunpy/visualization/wcsaxes_compat.py
--- a/sunpy/visualization/wcsaxes_compat.py
+++ b/sunpy/visualization/wcsaxes_compat.py
@@ -113,7 +113,7 @@ def default_wcs_grid(axes):
 
 
 @u.quantity_input
-def wcsaxes_heliographic_overlay(axes, grid_spacing: u.deg = 10*u.deg, **kwargs):
+def wcsaxes_heliographic_overlay(axes, grid_spacing: u.deg = 10*u.deg, annotate=True, **kwargs):
     """
     Create a heliographic overlay using
     `~astropy.visualization.wcsaxes.WCSAxes`.
@@ -126,6 +126,8 @@ def wcsaxes_heliographic_overlay(axes, grid_spacing: u.deg = 10*u.deg, **kwargs)
         The `~astropy.visualization.wcsaxes.WCSAxes` object to create the HGS overlay on.
     grid_spacing: `~astropy.units.Quantity`
         Spacing for longitude and latitude grid in degrees.
+    annotate : `bool`
+        Passing `False` disables the axes labels and the ticks on the top and right axes.
 
     Returns
     -------
@@ -158,11 +160,16 @@ def wcsaxes_heliographic_overlay(axes, grid_spacing: u.deg = 10*u.deg, **kwargs)
     lon.coord_wrap = 180
     lon.set_major_formatter('dd')
 
-    lon.set_axislabel('Solar Longitude', minpad=0.8)
-    lat.set_axislabel('Solar Latitude', minpad=0.9)
-
-    lon.set_ticks_position('tr')
-    lat.set_ticks_position('tr')
+    if annotate:
+        lon.set_axislabel('Solar Longitude', minpad=0.8)
+        lat.set_axislabel('Solar Latitude', minpad=0.9)
+        lon.set_ticks_position('tr')
+        lat.set_ticks_position('tr')
+    else:
+        lat.set_ticks_visible(False)
+        lon.set_ticks_visible(False)
+        lat.set_ticklabel_visible(False)
+        lon.set_ticklabel_visible(False)
 
     grid_kw = {'color': 'white', 'zorder': 100, 'alpha': 0.5}
     grid_kw.update(kwargs)


Test patch:
diff --git a/sunpy/map/tests/test_plotting.py b/sunpy/map/tests/test_plotting.py
--- a/sunpy/map/tests/test_plotting.py
+++ b/sunpy/map/tests/test_plotting.py
@@ -152,3 +152,8 @@ def test_heliographic_rectangle(heliographic_test_map):
     w = 13 * u.deg
     h = 13 * u.deg
     heliographic_test_map.draw_rectangle(bottom, w, h, color='cyan')
+
+@figure_test
+def test_heliographic_grid_annotations(heliographic_test_map):
+    heliographic_test_map.plot()
+    heliographic_test_map.draw_grid(annotate=False)
diff --git a/sunpy/tests/figure_hashes_py36.json b/sunpy/tests/figure_hashes_py36.json
--- a/sunpy/tests/figure_hashes_py36.json
+++ b/sunpy/tests/figure_hashes_py36.json
@@ -18,6 +18,7 @@
     "sunpy.map.tests.test_plotting.test_plot_masked_aia171_superpixel": "40d053eca1d23a24bec6b282978a30e0410b8a4e82286ace848b3c382c731c69",
     "sunpy.map.tests.test_plotting.test_plot_masked_aia171_superpixel_nowcsaxes": "0f0225378d2bd9820af2d2d526a804296496dcffa4e9a7659fc2bb91223a138b",
     "sunpy.map.tests.test_plotting.test_rectangle_aia171": "b59915b551c809d66149c7ea3687c01b186138f0c6893d9c308bf06850b089cc",
+    "sunpy.map.tests.test_plotting.test_heliographic_grid_annotations":"83b3e21c8b421789ed69c7b17175394f740621cf097b028d9e9122db057c3f58",
     "sunpy.timeseries.tests.test_timeseriesbase.test_esp_peek": "c25e927aaa39d576482a35438acee56fab915aede44e62744eb0bf2cefc889b4",
     "sunpy.timeseries.tests.test_timeseriesbase.test_eve_peek": "d2e7093fa95dc1a4bbde958275bba31d9061967ab5ef003d1af4f9519658d14b",
     "sunpy.timeseries.tests.test_timeseriesbase.test_fermi_gbm_peek": "dda01d15a769a3334e5254a93fd7bf8d16341f0e11cbd069f6738d8680bf6f96",
diff --git a/sunpy/tests/figure_hashes_py37.json b/sunpy/tests/figure_hashes_py37.json
--- a/sunpy/tests/figure_hashes_py37.json
+++ b/sunpy/tests/figure_hashes_py37.json
@@ -18,6 +18,7 @@
     "sunpy.map.tests.test_plotting.test_plot_masked_aia171_superpixel": "40d053eca1d23a24bec6b282978a30e0410b8a4e82286ace848b3c382c731c69",
     "sunpy.map.tests.test_plotting.test_plot_masked_aia171_superpixel_nowcsaxes": "0f0225378d2bd9820af2d2d526a804296496dcffa4e9a7659fc2bb91223a138b",
     "sunpy.map.tests.test_plotting.test_rectangle_aia171": "b59915b551c809d66149c7ea3687c01b186138f0c6893d9c308bf06850b089cc",
+    "sunpy.map.tests.test_plotting.test_heliographic_grid_annotations":"83b3e21c8b421789ed69c7b17175394f740621cf097b028d9e9122db057c3f58",
     "sunpy.timeseries.tests.test_timeseriesbase.test_esp_peek": "c25e927aaa39d576482a35438acee56fab915aede44e62744eb0bf2cefc889b4",
     "sunpy.timeseries.tests.test_timeseriesbase.test_eve_peek": "d2e7093fa95dc1a4bbde958275bba31d9061967ab5ef003d1af4f9519658d14b",
     "sunpy.timeseries.tests.test_timeseriesbase.test_fermi_gbm_peek": "dda01d15a769a3334e5254a93fd7bf8d16341f0e11cbd069f6738d8680bf6f96",