Skip to content

Fix pyplot.axis(ax) when ax is in other figure. #8043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 11, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix pyplot.axes(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.
  • Loading branch information
pavoljuhas committed Feb 7, 2017
commit 37d7f1f8a25bfac529922faac56532e8fa2c87c3
6 changes: 4 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,8 @@ def axes(*args, **kwargs):
color for the axis, default white.

- ``axes(h)`` where *h* is an axes instance makes *h* the current
axis. An :class:`~matplotlib.axes.Axes` instance is returned.
axis and the parent of *h* the current figure.
An :class:`~matplotlib.axes.Axes` instance is returned.

========= ============== ==============================================
kwarg Accepts Description
Expand Down Expand Up @@ -909,7 +910,8 @@ def axes(*args, **kwargs):
arg = args[0]

if isinstance(arg, Axes):
a = gcf().sca(arg)
sca(arg)
a = arg
else:
rect = arg
a = gcf().add_axes(rect, **kwargs)
Expand Down