8000 FIX: re-instate ability to have position in axes · matplotlib/matplotlib@56fcef5 · GitHub
[go: up one dir, main page]

Skip to content
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 56fcef5

Browse files
committed
FIX: re-instate ability to have position in axes
1 parent d448de3 commit 56fcef5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/matplotlib/pyplot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,12 @@ def axes(arg=None, **kwargs):
10591059
plt.axes((left, bottom, width, height), facecolor='w')
10601060
"""
10611061
fig = gcf()
1062+
pos = kwargs.pop('position', None)
10621063
if arg is None:
1063-
return fig.add_subplot(**kwargs)
1064+
if pos is None:
1065+
return fig.add_subplot(**kwargs)
1066+
else:
1067+
return fig.add_axes(pos, **kwargs)
10641068
else:
10651069
return fig.add_axes(arg, **kwargs)
10661070

lib/matplotlib/tests/test_pyplot.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import difflib
2+
import numpy as np
23
import subprocess
34
import sys
45
from pathlib import Path
@@ -320,3 +321,17 @@ def test_polar_second_call():
320321
ln2, = plt.polar(1.57, .5, 'bo')
321322
assert isinstance(ln2, mpl.lines.Line2D)
322323
assert ln1.axes is ln2.axes
324+
325+
326+
def test_fallback_position():
327+
# check that position kwarg works if rect not supplied
328+
axref = plt.axes([0.2, 0.2, 0.5, 0.5])
329+
axtest = plt.axes(position=[0.2, 0.2, 0.5, 0.5])
330+
np.testing.assert_allclose(axtest.bbox.get_points(),
331+
axref.bbox.get_points())
332+
333+
# check that position kwarg ignored if rect is supplied
334+
axref = plt.axes([0.2, 0.2, 0.5, 0.5])
335+
axtest = plt.axes([0.2, 0.2, 0.5, 0.5], position=[0.1, 0.1, 0.8, 0.8])
336+
np.testing.assert_allclose(axtest.bbox.get_points(),
337+
axref.bbox.get_points())

0 commit comments

Comments
 (0)
0