-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
gca(projection="rectilinear") fails to reset projection on axes #10700
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
We need to figure out exactly what
Note: All this is in the pyplot context, where there can be many Axes, Figures, and Images, but for each of these categories there is a single current one. In my suggestion, gca would not search through existing Axes--it would only check to see if it can use the current one. It would never modify or delete the current Axes. I think that part of the problem we are running into is confusion between gca as a user-level pyplot command, and our use of gca inside pyplot functions, like polar. Functions like gca and polar should be simple--they were supposed to be designed for casual users and quick use. We need to lay out the simple scenarios for their use, and construct and document them accordingly. If such a scenario includes |
Addendum: Looking at some code, I suspect my precise suggestion is not feasible (can't get there from here), but the basic points remain. |
I agree with @efiring's suggestion. In my interpretation, the main purpose is "getting the current axes" as the name says - no arguments required. As a fallback, if no axes exists, one is created which may need the parameters "get the current axes with these parameters". For a sane API If a function like Why exactly do you think a clean |
(fwiw I don't actually really care about what the exact semantics of |
Looking at this again I wonder whether the simple solution is not just to deprecate all kwargs to gca() (one can instead call |
Agreed, that I would still allow a bare |
Yes, gca() should still create an axes if none exists. |
This adds a small amount of additional state to the Axes created via Figure.add_axes and Figure.add_subplot (which the other Axes creation methods eventually funnel through) to track the projection class and (processed) kwargs. We then use that state in `pyplot.subplot` to determine if we should re-use an Axes found at a given position or create a new one (and implicitly destroy the existing one). This also changes the behavior of `plt.subplot` when no kwargs are passed to return the Axes at the location without doing any matching of the kwargs. As part of this work we also fixed two additional bugs: - you can now force Axes "back to" rectilinear Axes by passing projection='rectilinear' - Axes3D instances can now be re-selected at all closes matplotlib#19432 closes matplotlib#10700
This adds a small amount of additional state to the Axes created via Figure.add_axes and Figure.add_subplot (which the other Axes creation methods eventually funnel through) to track the projection class and (processed) kwargs. We then use that state in `pyplot.subplot` to determine if we should re-use an Axes found at a given position or create a new one (and implicitly destroy the existing one). This also changes the behavior of `plt.subplot` when no kwargs are passed to return the Axes at the location without doing any matching of the kwargs. As part of this work we also fixed two additional bugs: - you can now force Axes "back to" rectilinear Axes by passing projection='rectilinear' - Axes3D instances can now be re-selected at all closes matplotlib#19432 closes matplotlib#10700
This adds a small amount of additional state to the Axes created via Figure.add_axes and Figure.add_subplot (which the other Axes creation methods eventually funnel through) to track the projection class and (processed) kwargs. We then use that state in `pyplot.subplot` to determine if we should re-use an Axes found at a given position or create a new one (and implicitly destroy the existing one). This also changes the behavior of `plt.subplot` when no kwargs are passed to return the Axes at the location without doing any matching of the kwargs. As part of this work we also fixed two additional bugs: - you can now force Axes "back to" rectilinear Axes by passing projection='rectilinear' - Axes3D instances can now be re-selected at all closes matplotlib#19432 closes matplotlib#10700 Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
This adds a small amount of additional state to the Axes created via Figure.add_axes and Figure.add_subplot (which the other Axes creation methods eventually funnel through) to track the projection class and (processed) kwargs. We then use that state in `pyplot.subplot` to determine if we should re-use an Axes found at a given position or create a new one (and implicitly destroy the existing one). This also changes the behavior of `plt.subplot` when no kwargs are passed to return the Axes at the location without doing any matching of the kwargs. As part of this work we also fixed two additional bugs: - you can now force Axes "back to" rectilinear Axes by passing projection='rectilinear' - Axes3D instances can now be re-selected at all closes matplotlib#19432 closes matplotlib#10700 Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
This adds a small amount of additional state to the Axes created via Figure.add_axes and Figure.add_subplot (which the other Axes creation methods eventually funnel through) to track the projection class and (processed) kwargs. We then use that state in `pyplot.subplot` to determine if we should re-use an Axes found at a given position or create a new one (and implicitly destroy the existing one). This also changes the behavior of `plt.subplot` when no kwargs are passed to return the Axes at the location without doing any matching of the kwargs. As part of this work we also fixed two additional bugs: - you can now force Axes "back to" rectilinear Axes by passing projection='rectilinear' - Axes3D instances can now be re-selected at all closes matplotlib#19432 closes matplotlib#10700 Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
This adds a small amount of additional state to the Axes created via Figure.add_axes and Figure.add_subplot (which the other Axes creation methods eventually funnel through) to track the projection class and (processed) kwargs. We then use that state in `pyplot.subplot` to determine if we should re-use an Axes found at a given position or create a new one (and implicitly destroy the existing one). This also changes the behavior of `plt.subplot` when no kwargs are passed to return the Axes at the location without doing any matching of the kwargs. As part of this work we also fixed two additional bugs: - you can now force Axes "back to" rectilinear Axes by passing projection='rectilinear' - Axes3D instances can now be re-selected at all closes matplotlib#19432 closes matplotlib#10700 Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Bug report
Bug summary
As of 2.2:
shows a warning and replaces the originally created polar axes by a lambert axes (not sure what behavior we actually want this to have once axes-collision detection in add_axes is removed).
However, in
the second call to gca (using a rectilinear projection) fails to reset the projection at all and leaves the original polar axes in place.
Noted while thinking about #10674.
The text was updated successfully, but these errors were encountered: