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 aa413a8 commit e47efd1Copy full SHA for e47efd1
2 files changed
lib/matplotlib/pyplot.py
@@ -1232,6 +1232,7 @@ def subplot(*args, **kwargs):
1232
# If no existing axes match, then create a new one.
1233
if ax is None:
1234
ax = fig.add_subplot(*args, **kwargs)
1235
+ fig.sca(ax)
1236
1237
bbox = ax.bbox
1238
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