-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
MNT: only account for Artists once in fig.get_tightbbox #26899
Conversation
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.
Could this get a small test since this method is public anyways. I also wonder if this needs an API change note just in case people were somehow using this to get all artists on a figure?
ebf29ff
to
cf15285
Compare
Actually we can also leave the axes out from the list of artists as they are accounted for further down the matplotlib/lib/matplotlib/figure.py Lines 1722 to 1731 in ff552f4
@jklymak yep, I was wondering about the api change. Since the method is now just one list comprehension, we could put that list comprehension directly in |
I don't know if anyone really uses it this, but you could imagine passing a list of extra artists to The |
cf15285
to
b031de0
Compare
I believe I have evidence of a measurable performance gain here #26150 (comment). |
I think we should maybe leave the public method alone because it is a way to get a flat list of all artists you may want to query on a Figure. It could be better named for a more general purpose, but you could imagine folks are using it However, internally, we should probably stop using this method in favour of a hierarchy, as proposed here. |
b031de0
to
1c054c4
Compare
OK, I've removed the deprecation. What happens to the helper method clearly no longer affects the purpose of this PR. If someone has an opinion what to do with it (rename, deprecate,...) it could always be done separately. |
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.
Still makes sense to me.
PR summary
Figure.get_tightbbox
takes the union of the tightbbox's of all the artists attached to it. This includes each axes, whose tight_bbox incorporates all of their artists:matplotlib/lib/matplotlib/axes/_base.py
Lines 4442 to 4452 in ff552f4
So it seems redundant to me to also add in the axes' artists individually. Removing these lines did not break any tests for me locally.
PR checklist