Skip to content

Fix getting polar axes in plt.polar() #10674

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

Closed
wants to merge 2 commits into from

Conversation

dstansby
Copy link
Member

@dstansby dstansby commented Mar 4, 2018

Currently ax = gca(polar=True) raises a warning, because in future version it will return a new subplot instead of returning an existing one.

This PR removes this warning, and ensures plt.polar will behave well into the future by calling gca() without arguments. This means that if no axes are present, a new polar axes is manually created in plt.polar.

@dstansby dstansby added this to the v3.0 milestone Mar 4, 2018
@dstansby dstansby changed the title Remove gca() warning from test_axes Fix getting polar axes in plt.polar() Mar 5, 2018
"warning can be suppressed, and the future behavior "
"ensured, by passing a unique label to each axes "
"instance.")
"instance.\n"
Copy link
Member Author

Choose a reason for hiding this comment

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

Also added some newlines here to make the warning more readable.

ax = gca(polar=True)
ax = gca()
else:
ax = gcf().add_subplot(1, 1, 1, polar=True)
Copy link
Member

Choose a reason for hiding this comment

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

umm, I'm not too up on the pyplot interface, but is gca() necessarilly a subplot(111)?

Copy link
Member

Choose a reason for hiding this comment

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

No, but: If there are axes, use the gca(). If not, make a new one equivalent to subplot(111).

Copy link
Member

Choose a reason for hiding this comment

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

OK, but I don't get the point of this PR then. Why is this better than whats there now? Is the idea to let plt.polar write on an existing polar axes, despite the fact gca will create a new axes in the future? That doesn't seem right. Sorry if I'm being dense...

Copy link
Member

Choose a reason for hiding this comment

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

The whole gcasituation is incredibly confusing. I can't make sense of the current behavior and docstrings, and the warning about future behavior makes no sense to me either. gca means "get current axes"; it should not mean "always get a new axes". I think that the coming change to subplot is being incorrectly applied to gca.

Copy link
Member Author

Choose a reason for hiding this comment

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

The change was made in #10660 - I think gca should just get the current axis, and not create a new one, and that change should be reverted. ping @anntzer

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that the warning in #10660 is wrong. I need to rethink about the correct way to ultimately get rid of the axes collision behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great, I'll close this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants