Skip to content

Commit 9422ba3

Browse files
committed
Fix pyplot.axis(ax) when ax is in other figure.
Avoid crash when `ax` belongs to some other than the current figure. Make the `ax` owner the current figure instead.
1 parent c15694b commit 9422ba3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-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
if isinstance(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)

0 commit comments

Comments
 (0)