Skip to content

Commit a41d69b

Browse files
committed
TST: add test and fix issue with keyword
1 parent d8e3203 commit a41d69b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,8 @@ 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-
pos = kwargs.pop('position', None)
10641064
if pos is None:
10651065
return fig.add_subplot(**kwargs)
10661066
else:

lib/matplotlib/tests/test_pyplot.py

Lines changed: 13 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,15 @@ 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(), axref.bbox.get_points())
331+
332+
# check that position kwarg ignored if rect is supplied
333+
axref = plt.axes([0.2, 0.2, 0.5, 0.5])
334+
axtest = plt.axes([0.2, 0.2, 0.5, 0.5], position=[0.1, 0.1, 0.8, 0.8])
335+
np.testing.assert_allclose(axtest.bbox.get_points(), axref.bbox.get_points())

0 commit comments

Comments
 (0)