-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Remove deprecated axes kwargs collision detection #18978
Conversation
0f59282
to
8540c04
Compare
The Travis failure seems to be unrelated. |
Well, it looks like the changes to the OSS version of travis have finally caught up with us 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. |
There was a problem hiding this 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.
Discussion on call convinced me we need a bit more thinking.
#12513 for other discussion. |
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 in |
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)
assert ax0 == 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 kwargs
assert ax0 == ax1 # pass
ax2 = subplot(2, 1, 1, polar=True) # Warns about ignored kwargs
assert ax0 == 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, Ping @tacaswell, @anntzer, @timhoffm in case I got any of that incorrect. |
In Matplotlib 2.1, the behavior of reusing existing axes when created with the same arguments was deprecated (see matplotlib#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 to `gca` is deprecated. If `gca` is called with kwargs that do not match the current axes, then an exception is raised. Fixes matplotlib#18832.
8540c04
to
41b93d8
Compare
@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? |
I now understand the problem with twin axes. The method To avoid this issue, is it OK if the logic for reusing an existing subplot lives only in |
I think this PR was replaced by #19153. |
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 to
gca
is deprecated. Ifgca
is called with kwargs that do not match the current axes, then an exception is raised.Fixes #18832.
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).