Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b95065 commit 040e86dCopy full SHA for 040e86d
lib/matplotlib/pyplot.py
@@ -1233,6 +1233,7 @@ def subplot(*args, **kwargs):
1233
# If no existing axes matches, then create a new one.
1234
if ax is None or getattr(ax, '_projection_init', ()) != key:
1235
ax = fig.add_subplot(*args, **kwargs)
1236
+ fig.sca(ax)
1237
1238
bbox = ax.bbox
1239
axes_to_delete = []
lib/matplotlib/tests/test_pyplot.py
@@ -161,3 +161,12 @@ def test_close():
161
except TypeError as e:
162
assert str(e) == "close() argument must be a Figure, an int, " \
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
172
0 commit comments