>From f49143f34d9f71367344af359d53be170641f38c Mon Sep 17 00:00:00 2001
From: Andrew Straw <strawman@...36...>
Date: Thu, 21 May 2009 16:49:16 -0700
Subject: [PATCH 2/3] non-cartesian axes pass-through for dropped spines

---
 examples/api/custom_projection_example.py |   19 +++++++++++++++++--
 lib/matplotlib/projections/geo.py         |   19 +++++++++++++++++--
 lib/matplotlib/projections/polar.py       |   21 +++++++++++++++++++--
 3 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/examples/api/custom_projection_example.py b/examples/api/custom_projection_example.py
index 12ae0c5..29512b9 100644
--- a/examples/api/custom_projection_example.py
+++ b/examples/api/custom_projection_example.py
@@ -6,6 +6,8 @@ from matplotlib.ticker import Formatter, Locator, NullLocator, FixedLocator, Nul
 from matplotlib.transforms import Affine2D, Affine2DBase, Bbox, \
     BboxTransformTo, IdentityTransform, Transform, TransformWrapper
 from matplotlib.projections import register_projection
+import matplotlib.spines as mspines
+import matplotlib.axis as maxis
 
 import numpy as np
 
@@ -36,6 +38,14 @@ class HammerAxes(Axes):
         self.set_aspect(0.5, adjustable='box', anchor='C')
         self.cla()
 
+    def _init_axis(self):
+        self.xaxis = maxis.XAxis(self)
+        self.yaxis = maxis.YAxis(self)
+        # Do not register xaxis or yaxis with spines -- as done in
+        # Axes._init_axis() -- until HammerAxes.xaxis.cla() works.
+        # self.spines['hammer'].register_axis(self.yaxis)
+        self._update_transScale()
+
     def cla(self):
         """
         Override to set up some reasonable defaults.
@@ -167,11 +177,12 @@ class HammerAxes(Axes):
             yaxis_text_base + \
             Affine2D().translate(8.0, 0.0)
 
-    def get_xaxis_transform(self):
+    def get_xaxis_transform(self,which=None):
         """
         Override this method to provide a transformation for the
         x-axis grid and ticks.
         """
+        assert which in ['tick1','tick2','grid']
         return self._xaxis_transform
 
     def get_xaxis_text1_transform(self, pixelPad):
@@ -192,11 +203,12 @@ class HammerAxes(Axes):
         """
         return self._xaxis_text2_transform, 'top', 'center'
 
-    def get_yaxis_transform(self):
+    def get_yaxis_transform(self,which=None):
         """
         Override this method to provide a transformation for the
         y-axis grid and ticks.
         """
+        assert which in ['tick1','tick2','grid']
         return self._yaxis_transform
 
     def get_yaxis_text1_transform(self, pixelPad):
@@ -228,6 +240,9 @@ class HammerAxes(Axes):
         """
         return Circle((0.5, 0.5), 0.5)
 
+    def _gen_axes_spines(self):
+        return {'hammer':mspines.Spine(self,'hammer',Circle((0.5, 0.5), 0.5))}
+
     # Prevent the user from applying scales to one or both of the
     # axes.  In this particular case, scaling the axes wouldn't make
     # sense, so we don't allow it.
diff --git a/lib/matplotlib/projections/geo.py b/lib/matplotlib/projections/geo.py
index ad8e3cb..eef277d 100644
--- a/lib/matplotlib/projections/geo.py
+++ b/lib/matplotlib/projections/geo.py
@@ -10,6 +10,8 @@ from matplotlib.axes import Axes
 from matplotlib import cbook
 from matplotlib.patches import Circle
 from matplotlib.path import Path
+import matplotlib.spines as mspines
+import matplotlib.axis as maxis
 from matplotlib.ticker import Formatter, Locator, NullLocator, FixedLocator, NullFormatter
 from matplotlib.transforms import Affine2D, Affine2DBase, Bbox, \
     BboxTransformTo, IdentityTransform, Transform, TransformWrapper
@@ -36,6 +38,14 @@ class GeoAxes(Axes):
 
     RESOLUTION = 75
 
+    def _init_axis(self):
+        self.xaxis = maxis.XAxis(self)
+        self.yaxis = maxis.YAxis(self)
+        # Do not register xaxis or yaxis with spines -- as done in
+        # Axes._init_axis() -- until GeoAxes.xaxis.cla() works.
+        # self.spines['geo'].register_axis(self.yaxis)
+        self._update_transScale()
+
     def cla(self):
         Axes.cla(self)
 
@@ -111,7 +121,8 @@ class GeoAxes(Axes):
             .scale(0.5 / xscale, 0.5 / yscale) \
             .translate(0.5, 0.5)
 
-    def get_xaxis_transform(self):
+    def get_xaxis_transform(self,which=None):
+        assert which in ['tick1','tick2','grid']
         return self._xaxis_transform
 
     def get_xaxis_text1_transform(self, pad):
@@ -120,7 +131,8 @@ class GeoAxes(Axes):
     def get_xaxis_text2_transform(self, pad):
         return self._xaxis_text2_transform, 'top', 'center'
 
-    def get_yaxis_transform(self):
+    def get_yaxis_transform(self,which=None):
+        assert which in ['tick1','tick2','grid']
         return self._yaxis_transform
 
     def get_yaxis_text1_transform(self, pad):
@@ -132,6 +144,9 @@ class GeoAxes(Axes):
     def _gen_axes_patch(self):
         return Circle((0.5, 0.5), 0.5)
 
+    def _gen_axes_spines(self):
+        return {'geo':mspines.Spine(self,'geo',Circle((0.5, 0.5), 0.5))}
+
     def set_yscale(self, *args, **kwargs):
         if args[0] != 'linear':
             raise NotImplementedError
diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py
index 2bd5dd0..b987536 100644
--- a/lib/matplotlib/projections/polar.py
+++ b/lib/matplotlib/projections/polar.py
@@ -6,12 +6,14 @@ import matplotlib
 rcParams = matplotlib.rcParams
 from matplotlib.artist import kwdocd
 from matplotlib.axes import Axes
+import matplotlib.axis as maxis
 from matplotlib import cbook
 from matplotlib.patches import Circle
 from matplotlib.path import Path
 from matplotlib.ticker import Formatter, Locator
 from matplotlib.transforms import Affine2D, Affine2DBase, Bbox, \
     BboxTransformTo, IdentityTransform, Transform, TransformWrapper
+import matplotlib.spines as mspines
 
 class PolarAxes(Axes):
     """
@@ -213,6 +215,16 @@ class PolarAxes(Axes):
         self.xaxis.set_ticks_position('none')
         self.yaxis.set_ticks_position('none')
 
+    def _init_axis(self):
+        "move this out of __init__ because non-separable axes don't use it"
+        self.xaxis = maxis.XAxis(self)
+        self.yaxis = maxis.YAxis(self)
+        # Calling polar_axes.xaxis.cla() or polar_axes.xaxis.cla()
+        # results in weird artifacts. Therefore we disable this for
+        # now.
+        # self.spines['polar'].register_axis(self.yaxis)
+        self._update_transScale()
+
     def _set_lim_and_transforms(self):
         self.transAxes = BboxTransformTo(self.bbox)
 
@@ -269,7 +281,8 @@ class PolarAxes(Axes):
             self._yaxis_transform
             )
 
-    def get_xaxis_transform(self):
+    def get_xaxis_transform(self,which=None):
+        assert which in ['tick1','tick2','grid']
         return self._xaxis_transform
 
     def get_xaxis_text1_transform(self, pad):
@@ -278,7 +291,8 @@ class PolarAxes(Axes):
     def get_xaxis_text2_transform(self, pad):
         return self._xaxis_text2_transform, 'center', 'center'
 
-    def get_yaxis_transform(self):
+    def get_yaxis_transform(self,which=None):
+        assert which in ['tick1','tick2','grid']
         return self._yaxis_transform
 
     def get_yaxis_text1_transform(self, pad):
@@ -290,6 +304,9 @@ class PolarAxes(Axes):
     def _gen_axes_patch(self):
         return Circle((0.5, 0.5), 0.5)
 
+    def _gen_axes_spines(self):
+        return {'polar':mspines.Spine(self,'polar',Circle((0.5, 0.5), 0.5))}
+
     def set_rmax(self, rmax):
         self.viewLim.y0 = 0
         self.viewLim.y1 = rmax
-- 
1.6.2.1

