Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Faster title alignment#28300
Uh oh!
There was an error while loading.Please reload this page.
Conversation
rcomer commentedMay 25, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I admit I haven't actually figured outhow 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 withoutsharex suggests that this method ought to be fast and the real problem forsharex 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 fromxaxis.get_ticks_position()
and will prevent the unnecessary calls toxaxis.get_tightbbox
mentioned at#26150 (comment). Only checking the first tick is consistent withget_ticks_position.
There is a question in my mind about what happens if the ticks are pointing outward but unlabelled, but Ithink 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 inget_tightbbox
so actually this makes no difference.
rcomer commentedMay 28, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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?
Uh oh!
There was an error while loading.Please reload this page.
rcomer commentedMay 28, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 subplotand 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! |
9a9fce5
intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
We do; it ishere. However, we don't test |
Uh oh!
There was an error while loading.Please reload this page.
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