|
13 | 13 |
|
14 | 14 | import matplotlib as mpl |
15 | 15 | from matplotlib import gridspec, rcParams |
16 | | -from matplotlib._api.deprecation import MatplotlibDeprecationWarning |
17 | 16 | from matplotlib.testing.decorators import image_comparison, check_figures_equal |
18 | 17 | from matplotlib.axes import Axes |
19 | 18 | from matplotlib.figure import Figure, FigureBase |
@@ -189,62 +188,30 @@ def test_figure_legend(): |
189 | 188 | def test_gca(): |
190 | 189 | fig = plt.figure() |
191 | 190 |
|
| 191 | + # test that gca() picks up Axes created via add_axes() |
192 | 192 | ax0 = fig.add_axes([0, 0, 1, 1]) |
193 | | - with pytest.warns( |
194 | | - MatplotlibDeprecationWarning, |
195 | | - match=r'Calling gca\(\) with keyword arguments was deprecated'): |
196 | | - assert fig.gca(projection='rectilinear') is ax0 |
197 | 193 | assert fig.gca() is ax0 |
198 | 194 |
|
199 | | - ax1 = fig.add_axes(rect=[0.1, 0.1, 0.8, 0.8]) |
200 | | - with pytest.warns( |
201 | | - MatplotlibDeprecationWarning, |
202 | | - match=r'Calling gca\(\) with keyword arguments was deprecated'): |
203 | | - assert fig.gca(projection='rectilinear') is ax1 |
| 195 | + # test that gca() picks up Axes created via add_subplot() |
| 196 | + ax1 = fig.add_subplot(111) |
204 | 197 | assert fig.gca() is ax1 |
205 | 198 |
|
206 | | - ax2 = fig.add_subplot(121, projection='polar') |
207 | | - assert fig.gca() is ax2 |
208 | | - with pytest.warns( |
209 | | - MatplotlibDeprecationWarning, |
210 | | - match=r'Calling gca\(\) with keyword arguments was deprecated'): |
211 | | - assert fig.gca(polar=True) is ax2 |
212 | | - |
213 | | - ax3 = fig.add_subplot(122) |
214 | | - assert fig.gca() is ax3 |
215 | | - |
216 | | - with pytest.warns( |
217 | | - MatplotlibDeprecationWarning, |
218 | | - match=r'Calling gca\(\) with keyword arguments was deprecated'): |
219 | | - assert fig.gca(polar=True) is ax3 |
220 | | - with pytest.warns( |
221 | | - MatplotlibDeprecationWarning, |
222 | | - match=r'Calling gca\(\) with keyword arguments was deprecated'): |
223 | | - assert fig.gca(polar=True) is not ax2 |
224 | | - assert fig.gca().get_subplotspec().get_geometry() == (1, 2, 1, 1) |
225 | | - |
226 | 199 | # add_axes on an existing Axes should not change stored order, but will |
227 | 200 | # make it current. |
228 | 201 | fig.add_axes(ax0) |
229 | | - assert fig.axes == [ax0, ax1, ax2, ax3] |
| 202 | + assert fig.axes == [ax0, ax1] |
230 | 203 | assert fig.gca() is ax0 |
231 | 204 |
|
| 205 | + # sca() should not change stored order of Axes, which is order added. |
| 206 | + fig.sca(ax0) |
| 207 | + assert fig.axes == [ax0, ax1] |
| 208 | + |
232 | 209 | # add_subplot on an existing Axes should not change stored order, but will |
233 | 210 | # make it current. |
234 | | - fig.add_subplot(ax2) |
235 | | - assert fig.axes == [ax0, ax1, ax2, ax3] |
236 | | - assert fig.gca() is ax2 |
237 | | - |
238 | | - fig.sca(ax1) |
239 | | - with pytest.warns( |
240 | | - MatplotlibDeprecationWarning, |
241 | | - match=r'Calling gca\(\) with keyword arguments was deprecated'): |
242 | | - assert fig.gca(projection='rectilinear') is ax1 |
| 211 | + fig.add_subplot(ax1) |
| 212 | + assert fig.axes == [ax0, ax1] |
243 | 213 | assert fig.gca() is ax1 |
244 | 214 |
|
245 | | - # sca() should not change stored order of Axes, which is order added. |
246 | | - assert fig.axes == [ax0, ax1, ax2, ax3] |
247 | | - |
248 | 215 |
|
249 | 216 | def test_add_subplot_subclass(): |
250 | 217 | fig = plt.figure() |
|
0 commit comments