-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Axes order changed in 3.4.0rc1 #19598
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
Comments
So the issue here is that #19153 replaced To fix this (which I assume we do, since changing order changes draw order, which could do strange things), we either need to restore |
The stack can bubble entries to the top, which is what |
Sorry I erased my dumb comment. Was it necessary to remove _axesstack? Or just a nice simplification? |
Would have to ask @lpsinger to confirm, but I suspect it was removed because a) it was the private side of a deprecated-in-3.2 class, and b) it seemed to mostly be about tracking Axes keys at the time. We just didn't realize that tracking order was an important thing there, as it seems there were no tests that caught that. |
Yes, @QuLogic, that's correct. I'm not quite following your explanation of the bug, probably because I need more coffee! Is the issue that plt.colorbar() is bubbling itself and making itself the current axes? |
From a very quick guess, it may be possible to fix this by having a single module-wide private incrementing counter, assign indices to a private attribute ( |
I am confused. Why do we need to store the index in addition to the axes stack? |
Oh, I understand now. Originally, the indices were stored in the stack. According to the old docstring:
|
Why do we need to store the axes in a stack, at all? Why not just store them in a list, and keep track of the current axes as a member variable? The stack keeps track of the history of what the current axes was, but is that history ever actually needed? If we switched to storing the axes as a list, then that would automatically preserve the order in which they were added. |
I think that currently the sole usefulness of the stack is when using the pyplot interface, so that when you remove() the current (per gca()) axes, gca() then refers to the previously set current axes. |
Got it... should I resurrect the original implementation of storing the indices and axes in the stack? Maybe a simpler implementation would be store a stack and a list on the Figure. |
I don't have a strong preference here (... for now :)). |
Yes, the >>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> fig, ax = plt.subplots(2, 2)
>>> for (i, j), a in np.ndenumerate(ax):
... a.set_label(f'{i},{j}')
...
>>> fig.axes
[<AxesSubplot:label='0,0'>, <AxesSubplot:label='0,1'>, <AxesSubplot:label='1,0'>, <AxesSubplot:label='1,1'>]
>>> fig.sca(ax[0, 0])
<AxesSubplot:label='0,0'>
>>> fig.axes
[<AxesSubplot:label='0,1'>, <AxesSubplot:label='1,0'>, <AxesSubplot:label='1,1'>, <AxesSubplot:label='0,0'>] As this was not intended change, or communicated in any way before hand, I think we should do whatever is minimally possible to restore previous behaviour. |
Bug report
Bug summary
The order of the
axes
is changed in matplotlib 3.4.0rc1.Code for reproduction
Actual outcome
Expected outcome
Matplotlib version
import matplotlib; print(matplotlib.__version__)
): 3.4.0rc1print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineMatplotlib 3.4.0rc1 installed from pypi
The text was updated successfully, but these errors were encountered: