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