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

API: Remove deprecated axes kwargs collision detection#18978

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

Conversation

lpsinger
Copy link
Contributor

@lpsingerlpsinger commentedNov 19, 2020
edited
Loading

PR Summary

In Matplotlib 2.1, the behavior of reusing existing axes when created with the same arguments was deprecated (see#9037). This behavior is now removed.

Functions that create new axes (axes,add_axes,subplot, etc.) will now always create new axes, regardless of whether the kwargs passed to them match already existing axes.

Passing kwargs togca is deprecated. Ifgca is called with kwargs that do not match the current axes, then an exception is raised.

Fixes#18832.

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • [N/A] New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@lpsingerlpsingerforce-pushed thedo-not-detect-axes-collisions branch 4 times, most recently from0f59282 to8540c04CompareNovember 19, 2020 17:56
@tacaswelltacaswell added this to thev3.4.0 milestoneNov 19, 2020
@lpsinger
Copy link
ContributorAuthor

The Travis failure seems to be unrelated.

@tacaswell
Copy link
Member

tacaswell commentedNov 21, 2020
edited
Loading

Well, it looks like the changes to the OSS version of travis have finally caught up with ussafe to ignore that.

Reading more carefully the failure was unrelated to our builds getting suspended, it was trying to get an image from the network. I still agree we can disregard that for reviewing this PR.

tacaswell
tacaswell previously approved these changesNov 21, 2020
Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

I am still a bit worried about this as changing how how axes are created seems like it should get extra consideration, however this has been warning from 2.1 which is more than fair warning.

@tacaswelltacaswell changed the titleMNT: Remove deprecated axes kwargs collision detectionAPI: Remove deprecated axes kwargs collision detectionNov 24, 2020
@tacaswelltacaswell dismissed theirstale reviewNovember 24, 2020 20:52

Discussion on call convinced me we need a bit more thinking.

@tacaswell
Copy link
Member

#12513 for other discussion.

@tacaswell
Copy link
Member

Consusensus on the call was that we can not break

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

because as much as we think this is a bad idea (and holding onto the returned Axes object leads to significantly better code) there is no other way to "get back to" a previous axes using just the pyplot API. The logic for this re-use should fully live inpyplot.subplot and only check the subplot spec and warn if any kwargs are passed. The information we need to sort out if the given Axes exists in the Figure already exists on the Axes objects so we don't need to add any new state (just walk state we already have).

@jklymak
Copy link
Member

jklymak commentedNov 24, 2020
edited
Loading

EDIT: sorry cross post with above....

I've not looked at all the changes here carefully, but can try to do so. However, as discussed on the weekly call, we need to make sure

ax0=plt.subplot(2,1,1)plt.subplot(2,1,2)ax1=subplot(2,1,1)assertax0==ax1

still works, preferably without warning....

We did discuss the extra arguments case and decided that

ax0=plt.subplot(2,1,1,polar=True)plt.subplot(2,1,2)ax1=subplot(2,1,1,polar=False)#  Warns about ignored kwargsassertax0==ax1# passax2=subplot(2,1,1,polar=True)#  Warns about ignored kwargsassertax0==ax2# pass

should both warn that the second and third call has kwargs that are being ignored, rather than trying to check if the kwargs match the creation kwargs they should just be ignored. This precludes users from getting two axes over one another using pure pyplot, but they can still do this via non-pyplot:

ax0=fig.add_subplot(2,1,1,polar=True)ax1=fig.add_subplot(2,1,1,polar=False)# creates a *second* cartesian axes

Note that in that case,plt.subplot(2, 1, 1) will be somewhat ill-defined, in that it will return the first axes added.

Ping@tacaswell,@anntzer,@timhoffm in case I got any of that incorrect.

In Matplotlib 2.1, the behavior of reusing existing axes whencreated with the same arguments was deprecated (seematplotlib#9037). Thisbehavior is now removed.Functions that create new axes (`axes`, `add_axes`, `subplot`, etc.)will now always create new axes, regardless of whether the kwargspassed to them match already existing axes.Passing kwargs to `gca` is deprecated. If `gca` is called withkwargs that do not match the current axes, then an exception israised.Fixesmatplotlib#18832.
@lpsingerlpsingerforce-pushed thedo-not-detect-axes-collisions branch from8540c04 to41b93d8CompareDecember 6, 2020 19:39
@lpsinger
Copy link
ContributorAuthor

@tacaswell,@jklymak, I've attempted to implement that behavior, but I am getting some unit test failures related to twin axes, and I'm a bit stuck. Would you take a look, please?

@lpsinger
Copy link
ContributorAuthor

I now understand the problem with twin axes. The methodmatplotlib.axes._subplots.SubplotBase._make_twin_axes callsmatplotlib.figure.Figure.add_subplot, which in my implementation is still doing the key lookup.

To avoid this issue, is it OK if the logic for reusing an existing subplot livesonly inmatplotlib.pyplot.subplot, and not in its object-oriented siblingmatplotlib.figure.Figure.add_subplot?

@QuLogic
Copy link
Member

I think this PR was replaced by#19153.

jarrodmillman added a commit to jarrodmillman/scientific-python-lectures that referenced this pull requestSep 16, 2022
jarrodmillman added a commit to jarrodmillman/scientific-python-lectures that referenced this pull requestSep 16, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

Assignees
No one assigned
Projects
None yet
Milestone
v3.4.0
Development

Successfully merging this pull request may close these issues.

MNT: Remove AxesStack and deprecated behavior of reuse of existing axes with same arguments
4 participants
@lpsinger@tacaswell@jklymak@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp