Skip to content

Deprecate BBox.ignore() #17106

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 1 commit into from

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Apr 12, 2020

PR Summary

The code in the PR is preliminary. The deprecation may not be viable, pending discussion below.

Identified through the discussion in #17090.

Bbox.ignore() introduces a persistent state that affects whether Bbox.update_from_path() and Bbox.update_from_data_xy() will set the box extents to their arguments or join the argument extents with the existing extents. This hidden state can be confusing and is dangerous because it might be changed by other parts of the program without knowing.

However,

self.dataLim.ignore(True)
and

made me think, if this feature is needed for ignoring data limits (which IMHO would be a questionable design). If so, we'd need a different approach.

Comments welcome.

@anntzer
Copy link
Contributor

anntzer commented Apr 12, 2020

This has been in my todo list for a while, but as always "it's complicated". If you can pull it off that would be a rather nice simplification.

The basic idea (just a quick write up from memory, haven't rechecked) is that the "initial" data limits of a newly created axes is x=(0, 1), y=(0, 1) (so that these are the limits of an empty axes), but this bbox is marked as "ignore_existing_data_limits"/"ignore", so that once one adds data to it for the first time the data limits of that data completely overrides the 0-1. Note that this results in a slight inconsistency with what happens if you call plot() with no data; in that case Matplotlib knows it shouldn't use the "ignored" 0-1 limits but still has no data to autoscale on and thus relies on the nonsingular expander to expand the limits to (-0.05, 0.05). mplot3d has a similar mechanism, except that of course it's different and it uses the has_data() flag to know whether to ignore_existing_data_limits (again, just from my memory, some details may be wrong).

I'm not really sure whether we can choose to change the behavior of axes() to default to (-0.05, 0.05) instead or of an empty plot() to default to (0, 1) instead (these seem rather benign API changes, but what do I know...), but I do think it would likely be simpler if the initial data limits were "empty" (thus getting rid of the ignore_existing_data_limits flag) so that even the first plot can just do a normal datalimits bbox merge and if one wants to show such an empty plot we just rely on the normal nonsingular expander.

@brunobeltran
Copy link
Contributor

Didn't think there would be so much overlap when I started work on #17115, but now I see these issues are fundamentally linked. I'll keep that PR draft separate as it has a different goal....but will keep an eye on this, to avoid duplicating effort.

@timhoffm
Copy link
Member Author

I don't have the capacity to follow up on this. If somebody wants to take over, @anntzer's comment should be taken into account.

@timhoffm timhoffm closed this May 18, 2023
@timhoffm timhoffm deleted the deprecate-bbox-ignore branch July 19, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants