MNT: only account for Artists once in fig.get_tightbbox#26899
MNT: only account for Artists once in fig.get_tightbbox#26899QuLogic merged 1 commit intomatplotlib:mainfrom
Conversation
jklymak
left a comment
There was a problem hiding this comment.
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. |
PR summary
Figure.get_tightbboxtakes 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