File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -175,13 +175,18 @@ def subplot_class_factory(axes_class=None):
175
175
"is deprecated since %(since)s; explicitly pass the default Axes "
176
176
"class instead. This will become an error %(removal)s." )
177
177
axes_class = Axes
178
+
178
179
try :
179
180
# Avoid creating two different instances of GeoAxesSubplot...
180
181
# Only a temporary backcompat fix. This should be removed in
181
182
# 3.4
182
183
return next (cls for cls in SubplotBase .__subclasses__ ()
183
184
if cls .__bases__ == (SubplotBase , axes_class ))
184
185
except StopIteration :
186
+ # if we have already wrapped this class, declare victory!
187
+ if issubclass (axes_class , SubplotBase ):
188
+ return axes_class
189
+
185
190
return type ("%sSubplot" % axes_class .__name__ ,
186
191
(SubplotBase , axes_class ),
187
192
{'_axes_class' : axes_class })
Original file line number Diff line number Diff line change 5
5
6
6
import matplotlib .pyplot as plt
7
7
from matplotlib .testing .decorators import image_comparison
8
+ import matplotlib .axes as maxes
8
9
9
10
10
11
def check_shared (axs , x_shared , y_shared ):
@@ -195,3 +196,8 @@ def test_dont_mutate_kwargs():
195
196
gridspec_kw = gridspec_kw )
196
197
assert subplot_kw == {'sharex' : 'all' }
197
198
assert gridspec_kw == {'width_ratios' : [1 , 2 ]}
199
+
200
+
201
+ def test_subplot_factory_reapplication ():
202
+ assert maxes .subplot_class_factory (maxes .Axes ) is maxes .Subplot
203
+ assert maxes .subplot_class_factory (maxes .Subplot ) is maxes .Subplot
You can’t perform that action at this time.
0 commit comments