@@ -187,6 +187,18 @@ def _make_twin_axes(self, *kl, **kwargs):
187187 return ax2
188188
189189
190+ # this here to support cartopy which was using a private part of the
191+ # API to register their Axes subclasses.
192+
193+ # In 3.1 this should be changed to a dict subclass that warns on use
194+ # In 3.3 to a dict subclass that raises a useful exception on use
195+ # In 3.4 should be removed
196+
197+ # The slow timeline is to give cartopy enough time to get several
198+ # release out before we break them.
199+ _subplot_classes = {}
200+
201+
190202@functools .lru_cache (None )
191203def subplot_class_factory (axes_class = None ):
192204 """
@@ -198,9 +210,16 @@ def subplot_class_factory(axes_class=None):
198210 """
199211 if axes_class is None :
200212 axes_class = Axes
201- return type ("%sSubplot" % axes_class .__name__ ,
202- (SubplotBase , axes_class ),
203- {'_axes_class' : axes_class })
213+ try :
214+ # Avoid creating two different instances of GeoAxesSubplot...
215+ # Only a temporary backcompat fix. This should be removed in
216+ # 3.4
217+ return next (cls for cls in SubplotBase .__subclasses__ ()
218+ if cls .__bases__ == (SubplotBase , axes_class ))
219+ except StopIteration :
220+ return type ("%sSubplot" % axes_class .__name__ ,
221+ (SubplotBase , axes_class ),
222+ {'_axes_class' : axes_class })
204223
205224
206225# This is provided for backward compatibility
0 commit comments