Repository: sunpy/sunpy

Issue:
Animation of mapcube failing
A user has reported the failure of mapcube animation.  See the traceback below.  The bug is that the map coordinate_system property changed from using the SpatialPair tuple with 'x y' to a SpatialPair tuple with 'axis1 axis2', but the axis to these values in mapcube.py was not updated.  This is likely not the only place this has happened.  The fix should be relatively easy if this is indeed the bug.

```
Traceback (most recent call last):

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5agg.py", line 197, in __draw_idle_agg
FigureCanvasAgg.draw(self)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 464, in draw
self.figure.draw(self.renderer)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/figure.py", line 1151, in draw
self.canvas.draw_event(renderer)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 1823, in draw_event
self.callbacks.process(s, event)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/cbook.py", line 554, in process
proxy(*args, **kwargs)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/cbook.py", line 416, in call
return mtd(*args, **kwargs)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 881, in _start
self._init_draw()

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 1540, in _init_draw
self._draw_frame(next(self.new_frame_seq()))

File "/media/solar1/anaconda3/lib/python3.6/site-packages/matplotlib/animation.py", line 1562, in _draw_frame
self._drawn_artists = self._func(framedata, *self._args)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/sunpy/map/mapcube.py", line 227, in updatefig
annotate_frame(i)

File "/media/solar1/anaconda3/lib/python3.6/site-packages/sunpy/map/mapcube.py", line 181, in annotate_frame

if self[0].coordinate_system.x == 'HG':
AttributeError: 'SpatialPair' object has no attribute 'x'
```


Discussion:

Resolving patch:
diff --git a/sunpy/map/mapcube.py b/sunpy/map/mapcube.py
--- a/sunpy/map/mapcube.py
+++ b/sunpy/map/mapcube.py
@@ -13,6 +13,7 @@
 from sunpy.map import GenericMap
 from sunpy.visualization.mapcubeanimator import MapCubeAnimator
 from sunpy.visualization import wcsaxes_compat
+from sunpy.visualization import axis_labels_from_ctype
 from sunpy.util import expand_list
 from sunpy.extern.six.moves import range
 
@@ -91,7 +92,7 @@ def __len__(self):
     # Sorting methods
     @classmethod
     def _sort_by_date(cls):
-        return lambda m: m.date # maps.sort(key=attrgetter('date'))
+        return lambda m: m.date  # maps.sort(key=attrgetter('date'))
 
     def _derotate(self):
         """Derotates the layers in the MapCube"""
@@ -176,21 +177,10 @@ def plot(self, axes=None, resample=None, annotate=True,
         # Normal plot
         def annotate_frame(i):
             axes.set_title("{s.name}".format(s=self[i]))
-
-            # x-axis label
-            if self[0].coordinate_system.x == 'HG':
-                xlabel = 'Longitude [{lon}'.format(lon=self[i].spatial_units.x)
-            else:
-                xlabel = 'X-position [{xpos}]'.format(xpos=self[i].spatial_units.x)
-
-            # y-axis label
-            if self[0].coordinate_system.y == 'HG':
-                ylabel = 'Latitude [{lat}]'.format(lat=self[i].spatial_units.y)
-            else:
-                ylabel = 'Y-position [{ypos}]'.format(ypos=self[i].spatial_units.y)
-
-            axes.set_xlabel(xlabel)
-            axes.set_ylabel(ylabel)
+            axes.set_xlabel(axis_labels_from_ctype(self[i].coordinate_system[0],
+                                                   self[i].spatial_units[0]))
+            axes.set_ylabel(axis_labels_from_ctype(self[i].coordinate_system[1],
+                                                   self[i].spatial_units[1]))
 
         if resample:
             if self.all_maps_same_shape():


Test patch: