File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1233,6 +1233,7 @@ def subplot(*args, **kwargs):
1233
1233
# If no existing axes matches, then create a new one.
1234
1234
if ax is None or getattr (ax , '_projection_init' , ()) != key :
1235
1235
ax = fig .add_subplot (* args , ** kwargs )
1236
+ fig .sca (ax )
1236
1237
1237
1238
bbox = ax .bbox
1238
1239
axes_to_delete = []
Original file line number Diff line number Diff line change @@ -161,3 +161,12 @@ def test_close():
161
161
except TypeError as e :
162
162
assert str (e ) == "close() argument must be a Figure, an int, " \
163
163
"a string, or None, not <class 'float'>"
164
+
165
+
166
+ def test_subplot_reuse ():
167
+ ax1 = plt .subplot (121 )
168
+ assert ax1 is plt .gca ()
169
+ ax2 = plt .subplot (122 )
170
+ assert ax2 is plt .gca ()
171
+ ax1 = plt .subplot (121 )
172
+ assert ax1 is plt .gca ()
You can’t perform that action at this time.
0 commit comments