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

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

Merged

Conversation

pavoljuhas
Copy link
Contributor

Avoid crash whenax belongs to some other than the current figure.
Make theax owner the current figure instead.

This resolves crash inaxes call in the following stanza

frommatplotlib.pyplotimport*f1,a1=subplots()f2,a2=subplots()axes(a1)assertgca()isa1assertgcf()isf1

Avoid crash when `ax` belongs to some other than the current figure.Make the `ax` owner the current figure instead.
@pavoljuhaspavoljuhasforce-pushed thefix-pyplot-axes-in-other-figure branch from9422ba3 to37d7f1fCompareFebruary 7, 2017 23:56
@dopplershift
Copy link
Contributor

Is there any chance you could add a test intest_axes.py that replicates the crash? It could be as simple as:

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.

@pavoljuhas
Copy link
ContributorAuthor

Sure, I'll get to it later today or tomorrow.

Ensure `ax` becomes the current axis and its parent the current figure.
@tacaswelltacaswell added this to the2.1 (next point release) milestoneFeb 8, 2017
Copy link
Member

@NelleVNelleV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM
Thanks!

@NelleVNelleV changed the titleFix pyplot.axis(ax) when ax is in other figure.[MRG+1] Fix pyplot.axis(ax) when ax is in other figure.Feb 10, 2017
@dstansby
Copy link
Member

dstansby commentedFeb 10, 2017
edited
Loading

Thanks for the fix! 🤦‍♂️ I should check the tests before I approve something next time.

Copy link
Member

@dstansbydstansby left a 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.

# test focusing of Axes in other Figure
fig1, ax1 = subplots()
fig2, ax2 = subplots()
assert ax1 is plt.axes(ax1)
Copy link
Member

@dstansbydstansbyFeb 10, 2017
edited
Loading

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()

Copy link
Member

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.

Copy link
Member

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

Copy link
ContributorAuthor

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.

@@ -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()
Copy link
Member

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?

Copy link
ContributorAuthor

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.

@NelleVNelleV merged commit3d99e43 intomatplotlib:masterFeb 11, 2017
@pavoljuhaspavoljuhas deleted the fix-pyplot-axes-in-other-figure branchFebruary 11, 2017 18:13
@QuLogicQuLogic changed the title[MRG+1] Fix pyplot.axis(ax) when ax is in other figure.Fix pyplot.axis(ax) when ax is in other figure.Feb 12, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@NelleVNelleVNelleV approved these changes

@dstansbydstansbydstansby approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

6 participants
@pavoljuhas@dopplershift@dstansby@NelleV@QuLogic@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp