Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2193652

Browse filesBrowse files
committed
Disallow figure argument for pyplot.subplot() and Figure.add_subplot()
1 parent 1956b1d commit 2193652
Copy full SHA for 2193652

File tree

Expand file treeCollapse file tree

3 files changed

+18
-6
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-6
lines changed
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
API changes
2+
```````````
3+
4+
`.Figure.add_subplot()` and `.pyplot.subplot()` do not accept a `figure`
5+
keyword argument anymore. It only used to work anyway if the passed figure
6+
was ``self`` or the current figure, respectively.

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,9 +1301,9 @@ def add_subplot(self, *args, **kwargs):
13011301
Other Parameters
13021302
----------------
13031303
**kwargs
1304-
This method also takes the keyword arguments for
1305-
the returned axes base class. The keyword arguments for the
1306-
rectilinear base class `~.axes.Axes` can be found in
1304+
This method also takes the keyword arguments for the returned axes
1305+
base class; except for the *figure* argument. The keyword arguments
1306+
for the rectilinear base class `~.axes.Axes` can be found in
13071307
the following table but there might also be other keyword
13081308
arguments if another projection is used.
13091309
%(Axes)s
@@ -1376,6 +1376,12 @@ def add_subplot(self, *args, **kwargs):
13761376
"three-digit number, not {}".format(args[0]))
13771377
args = tuple(map(int, str(args[0])))
13781378

1379+
if 'figure' in kwargs:
1380+
# Axes itself allows for a 'figure' kwarg, but since we want to
1381+
# bind the created Axes to self, it is not allowed here.
1382+
raise TypeError(
1383+
"add_subplot() got an unexpected keyword argument 'figure'")
1384+
13791385
if isinstance(args[0], SubplotBase):
13801386

13811387
a = args[0]

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,9 @@ def subplot(*args, **kwargs):
912912
Other Parameters
913913
----------------
914914
**kwargs
915-
This method also takes the keyword arguments for
916-
the returned axes base class. The keyword arguments for the
917-
rectilinear base class `~.axes.Axes` can be found in
915+
This method also takes the keyword arguments for the returned axes
916+
base class; except for the *figure* argument. The keyword arguments
917+
for the rectilinear base class `~.axes.Axes` can be found in
918918
the following table but there might also be other keyword
919919
arguments if another projection is used.
920920
%(Axes)s

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.