Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Copy all internals from initial Tick to lazy ones #28577

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

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jul 15, 2024

PR summary

Ticks will follow the rcParams at the time of their creation, if there were no other settings used. If the rcParams are set in a context, then the lazily-generated ticks may start fetching the wrong values. This is fixed via Axis._copy_tick_props by copying the properties from the Tick's child Artist's to the new ones. However, internal attributes from Tick are not copied, which is generally fine for drawing because nothing is every re-synced from there.

However, in the case of Spine's window extent, it is generated from the tick direction and size attributes on the Tick, so being out of sync may cause an incorrect bounding box if the tick direction changes. Since Spine chooses a random Tick, this will cause tight/constrained layout to be nondeterministic.

Since this is nondeterministic, I'm debating how best to write a test.

Fixes #28574.

PR checklist

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great detective work!

@timhoffm
Copy link
Member

@QuLogic decide yourself if / how to test this. May self-merge, then.

This is used only for XTick._apply_tickdir, and YTick._apply_tickdir
uses a different dictionary.
@QuLogic
Copy link
Member Author

QuLogic commented Jul 24, 2024

I wasn't able to find a good way to test the layout portion directly, so I went with the more straightforward, though perhaps tautological, version of just asserting the copied attributes.

I also made one more change of adding a dest.update_from(src) so that the main tick properties are copied. I don't believe we use any of them, but this is just in case that happens in the future.

@ksunden ksunden added this to the v3.9.2 milestone Aug 7, 2024
@ksunden ksunden merged commit 3d37d7a into matplotlib:main Aug 7, 2024
42 of 44 checks passed
@QuLogic QuLogic deleted the fix-tickdir branch August 7, 2024 20:48
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Aug 7, 2024
oscargus added a commit that referenced this pull request Aug 8, 2024
…577-on-v3.9.x

Backport PR #28577 on branch v3.9.x (Copy all internals from initial Tick to lazy ones)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Nondeterministic behavior with subplot spacing and constrained layout
4 participants