Skip to content
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

MNT: Deprecate plt.polar() with an existing non-polar Axes #28946

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Oct 7, 2024

Before, we only issued a warning. But we clearly cannot fulfill the intention of a polar plot and therefore we should error out instead of just warn.

Also document that polar() should typically be called first to prevent having a non-polar Axes already created.

Closes #28944.

@timhoffm timhoffm force-pushed the mnt-pyplot-polar branch 3 times, most recently from 7edef3a to c2be3e8 Compare October 7, 2024 11:50
lib/matplotlib/pyplot.py Outdated Show resolved Hide resolved
@tacaswell tacaswell added this to the v3.11.0 milestone Oct 7, 2024
Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

👍🏻 , but I would like to hold this until after we branch 3.10.x and it needs an API change note.

Although I am coming down in favor of doing this, I'm a bit torn. Clearly what it is doing now is not what anyone wants, but it is not "wrong". Introducing a new hard-fail is a breaking change to what I believe is long standing behavior so needs an API change note and I would like to defer it to 3.11 to have a bit more time (and early adopters) to try it.

@timhoffm
Copy link
Member Author

timhoffm commented Oct 7, 2024

IMHO the current behavior is actually "wrong". Not wrong in the sense that pyplot works exactly to its rules, but logically wrong: If I write plt.polar(...) I clearly expect the data to show up in a polar Axes. It's surprising and nobody helped with that the data may end up in a rectilinear Axes. Since we cannot fulfill the polar Axes according to pyplot Axes-reuse rule if another Axes has already been created, the only reasonable action is to deny the operation and error out.

While this is technically a breaking change, I'm not worried about it. Every affected use case I can imagine, is a hidden error that does not do what the user wants, and it's justifiable to surface that immediately through an exception.
But if you are seriously concerned about the breaking change, we could also officially deprecate the behavior (then maybe already for 3.10? but OTOH it's not urgent) and turn it into an error later.

@WeatherGod
Copy link
Member

WeatherGod commented Oct 7, 2024 via email

Before, we only issued a warning. But we clearly cannot fulfill the intention
of a polar plot and therefore we should error out instead of just warn.

Also document that `polar()` should typically be called first to prevent having
a non-polar Axes already created.
@timhoffm
Copy link
Member Author

I've heard the concerns and turned it into a regular deprecation rather than an immediate failure.

But then, I'd like to punt back to 3.10 to get the deprecation rolling.

@timhoffm timhoffm dismissed tacaswell’s stale review October 28, 2024 12:45

Changed into a regular deprecation.

@timhoffm timhoffm modified the milestones: v3.11.0, v3.10.0 Oct 28, 2024
@timhoffm timhoffm changed the title MNT: Error out if plt.polar() is called with an existing non-polar Axes MNT: Deprecate plt.polar() with an existing non-polar Axes Oct 28, 2024
@greglucas greglucas merged commit bda958a into matplotlib:main Oct 29, 2024
43 checks passed
@greglucas
Copy link
Contributor

👍 to the deprecation note. If someone complains, they can then fix it and we can change this note.

@timhoffm timhoffm deleted the mnt-pyplot-polar branch October 29, 2024 21:36
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.

[Bug]: calling title before making polar plot
5 participants