Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix pyplot.axis(ax) when ax is in other figure.#8043
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Avoid crash when `ax` belongs to some other than the current figure.Make the `ax` owner the current figure instead.
9422ba3
to37d7f1f
CompareIs there any chance you could add a test in deftest_set_axes_different_figure():f1,a1=plt.subplots()f2,a2=plt.subplots()plt.axes(a1)assertplt.gca()isa1assertplt.gcf()isf1 This way we don't accidentally break it in the future. |
Sure, I'll get to it later today or tomorrow. |
Ensure `ax` becomes the current axis and its parent the current figure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
Thanks!
dstansby commentedFeb 10, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Just a couple of test fixes needed.
lib/matplotlib/tests/test_axes.py Outdated
# test focusing of Axes in other Figure | ||
fig1, ax1 = subplots() | ||
fig2, ax2 = subplots() | ||
assert ax1 is plt.axes(ax1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
These two lines need to beplt.subplots()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This comment is one line below where it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Woops, thanks for spotting that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed - thanks for catching that.
lib/matplotlib/tests/test_axes.py Outdated
@@ -1476,6 +1476,15 @@ def _as_mpl_axes(self): | |||
'Expected a PolarAxesSubplot, got %s' % type(ax) | |||
plt.close() | |||
# test focusing of Axes in other Figure | |||
fig1, ax1 = subplots() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Could the new lines go in a new function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Indeedtest_as_mpl_axes_api
seems to be for customizations with the_as_mpl_axes
function. I will add the new function.
Avoid crash when
ax
belongs to some other than the current figure.Make the
ax
owner the current figure instead.This resolves crash in
axes
call in the following stanza