10000 throw deprecation warning on empty call to fig.add_axes() by KSafran · Pull Request #15286 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

throw deprecation warning on empty call to fig.add_axes() #15286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/deprecated_empty_add_axes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deprecations
````````````

Calling ``fig.add_axes()`` with no arguments currently return None,
will raise an error in the future
5 changes: 5 additions & 0 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,11 @@ def add_axes(self, *args, **kwargs):
"""

if not len(args):
cbook.warn_deprecated(
"3.3",
message="Calling add_axes() without argument is "
"deprecated. You may want to use add_suplot() "
"instead.")
return

# shortcut the projection "key" modifications later on, if an axes
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def test_figure_legend():
def test_gca():
fig = plt.figure()

with pytest.warns(UserWarning):
# empty call to add_axes() will throw deprecation warning
assert fig.add_axes() is None

ax1 = fig.add_axes([0, 0, 1, 1])
assert fig.gca(projection='rectilinear') is ax1
assert fig.gca() is ax1
Expand Down
0