Skip to content

Always create a new subplot in plt.subplot() #19434

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 Feb 2, 2021

Fixes #19432.

The behaviour before this patch was to return an existing Axes if it had the same subplot-spec, regardless of **kwargs. This changes that to always create a new Axes, which is what is documented and expected from the deprecation.

@dstansby dstansby added this to the v3.4.0 milestone Feb 2, 2021
@dstansby
Copy link
Member Author

dstansby commented Feb 2, 2021

Woops, looks like I missed #18978 (comment), ie.

plt.subplot(222)
plt.subplot(222)

should return the same axes, so this is going to need a bit more thought.

@dstansby dstansby marked this pull request as draft February 2, 2021 14:24
@dstansby dstansby closed this Feb 2, 2021
@astrofrog
Copy link
Contributor

Can't the behavior be that the same axes are returned assuming no projections/kwargs are present, and otherwise new axes are returned?

@dstansby
Copy link
Member Author

dstansby commented Feb 2, 2021

Yeah, I think that's what should happen - currently working on it.

@astrofrog
Copy link
Contributor

astrofrog commented Feb 2, 2021

@dstansby an alternative is to do as suggested in #18978 (comment) but then a warning does need to be raised as opposed to the current silent behavior. I'm not a fan of the axes reuse but if there is consensus about keeping the new behavior a warning has to be emitted (not just deprecation to be clear)

@dstansby dstansby deleted the axes-creation branch February 2, 2021 14:49
@QuLogic QuLogic removed this from the v3.4.0 milestone Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected change in behavior in plt.subplot
3 participants