Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit3d7dea5

Browse files
authored
Merge pull request#21443 from jklymak/fix-position-axes
FIX: re-instate ability to have position in axes
2 parentsc316142 +56fcef5 commit3d7dea5

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
ifargisNone:
1063-
returnfig.add_subplot(**kwargs)
1064+
ifposisNone:
1065+
returnfig.add_subplot(**kwargs)
1066+
else:
1067+
returnfig.add_axes(pos,**kwargs)
10641068
else:
10651069
returnfig.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
importdifflib
2+
importnumpyasnp
23
importsubprocess
34
importsys
45
frompathlibimportPath
@@ -320,3 +321,17 @@ def test_polar_second_call():
320321
ln2,=plt.polar(1.57,.5,'bo')
321322
assertisinstance(ln2,mpl.lines.Line2D)
322323
assertln1.axesisln2.axes
324+
325+
326+
deftest_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)

[8]ページ先頭

©2009-2025 Movatter.jp