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

Commit3d99e43

Browse files
authored
Merge pull request#8043 from pavoljuhas/fix-pyplot-axes-in-other-figure
Fix pyplot.axis(ax) when ax is in other figure.
2 parents96c75be +2fa64ad commit3d99e43

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

‎lib/matplotlib/pyplot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,8 @@ def axes(*args, **kwargs):
875875
color for the axis, default white.
876876
877877
- ``axes(h)`` where *h* is an axes instance makes *h* the current
878-
axis. An :class:`~matplotlib.axes.Axes` instance is returned.
878+
axis and the parent of *h* the current figure.
879+
An :class:`~matplotlib.axes.Axes` instance is returned.
879880
880881
========= ============== ==============================================
881882
kwarg Accepts Description
@@ -909,7 +910,8 @@ def axes(*args, **kwargs):
909910
arg=args[0]
910911

911912
ifisinstance(arg,Axes):
912-
a=gcf().sca(arg)
913+
sca(arg)
914+
a=arg
913915
else:
914916
rect=arg
915917
a=gcf().add_axes(rect,**kwargs)

‎lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,17 @@ def _as_mpl_axes(self):
14771477
plt.close()
14781478

14791479

1480+
deftest_pyplot_axes():
1481+
# test focusing of Axes in other Figure
1482+
fig1,ax1=plt.subplots()
1483+
fig2,ax2=plt.subplots()
1484+
assertax1isplt.axes(ax1)
1485+
assertax1isplt.gca()
1486+
assertfig1isplt.gcf()
1487+
plt.close(fig1)
1488+
plt.close(fig2)
1489+
1490+
14801491
@image_comparison(baseline_images=['log_scales'])
14811492
deftest_log_scales():
14821493
fig=plt.figure()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp