Skip to content

Commit 31e7ceb

Browse files
committed
deprecate fig.add_axes() with no arguments
1 parent 8d17939 commit 31e7ceb

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
Calling ``fig.add_axes()`` with no arguments currently return None,
5+
will raise an error in the future

lib/matplotlib/figure.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,11 @@ def add_axes(self, *args, **kwargs):
12211221
"""
12221222

12231223
if not len(args):
1224+
cbook.warn_deprecated(
1225+
"3.3",
1226+
message="Calling add_axes() without argument is "
1227+
"deprecated. You may want to use add_suplot() "
1228+
"instead.")
12241229
return
12251230

12261231
# shortcut the projection "key" modifications later on, if an axes

lib/matplotlib/tests/test_figure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def test_figure_legend():
141141
def test_gca():
142142
fig = plt.figure()
143143

144+
with pytest.warns(UserWarning):
145+
# empty call to add_axes() will throw deprecation warning
146+
assert fig.add_axes() is None
147+
144148
ax1 = fig.add_axes([0, 0, 1, 1])
145149
assert fig.gca(projection='rectilinear') is ax1
146150
assert fig.gca() is ax1

0 commit comments

Comments
 (0)