-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Faster title alignment #28300
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
Faster title alignment #28300
Conversation
I admit I haven't actually figured out how the first change made the given example faster. Edit: |
I think this would benefit from more digging: the fact that there is no measurable time difference without sharex suggests that this method ought to be fast and the real problem for sharex is deeper. |
More digging completed #26150 (comment) |
xticklabel_top = any(tick.label2.get_visible() for tick in | ||
[ax.xaxis.majorTicks[0], ax.xaxis.minorTicks[0]]) |
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.
Directly check the visibility of the tick label as I think that is the most relevant part from xaxis.get_ticks_position()
and will prevent the unnecessary calls to xaxis.get_tightbbox
mentioned at #26150 (comment). Only checking the first tick is consistent with get_ticks_position.
There is a question in my mind about what happens if the ticks are pointing outward but unlabelled, but I think that could already be an issue with the existing approach as you could have "default" position and outward ticks. Edit: the ticks themselves aren't included in get_tightbbox
so actually this makes no difference.
I think CodeCov was telling me that we didn't have any tests with a child axes and an automatically positioned title, so I added one. |
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.
This seems good to me. Does it actually speed things up?
If I take this example from #26150 With
with this branch
That example has no titles though, so we are now just skipping everything. If I add a title to each subplot I get
Branch
If I add a title to each subplot and move the ticklabels to the top of each subplot, so we do actually need to calculate
Branch
|
We have a benchmarking test suite. I wonder if these are caught by it? @QuLogic maintains that - I actually forget where it is... |
This is news to me! |
We do; it is here. However, we don't test |
PR summary
top
does not depend ontitle
, so move it outside the loop.I used
fig_many.savefig(stream, format='svg', bbox_inches='tight')
andfig_many_sharex.savefig(stream, format='svg', bbox_inches='tight')
from #26150 as benchmarks.fig_many.savefig
ran in ~320-330 ms regardless of this change. Forfig_many_sharex
I gotWith
main
:After (1)
After (2)
PR checklist