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.
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. |
jklymak
left a comment
There was a problem hiding this comment.
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
topdoes 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.savefigran in ~320-330 ms regardless of this change. Forfig_many_sharexI gotWith
main:After (1)
After (2)
PR checklist