Add WilkinsonLocator using Extended Wilkinson Algorithm#31393
Add WilkinsonLocator using Extended Wilkinson Algorithm#31393Aryan-Gore wants to merge 1 commit intomatplotlib:mainfrom
Conversation
|
From #31391 It would also make sense to be able to specify Q (call it steps like for the MaxNLocator). Why is [0, 25, 50, 75, 100] always better than [0, 20, 40, 60, 80, 100]? Wouldn't that depend on other things? (Next time, please to a |
ok i will add steps and You’re right about [0, 25, 50, 75, 100] vs [0, 20, 40, 60, 80, 100] — the “better” choice depends on context, so the algorithm can be adjusted to score niceness more flexibly rather than hardcoding it. and sorry for redundant commits, it is my first contribution to open source . |
This PR introduces a new tick locator, WilkinsonLocator, based on the Extended Wilkinson Algorithm for generating aesthetically pleasing and well-distributed axis ticks.
What problem does it solve?
This implementation improves tick placement by optimizing:
Simplicity (nice round numbers like 25 instead of 20)
Coverage (ensures the full axis range is represented)
Density (avoids overcrowding of ticks)
What is the reasoning for this implementation?
The locator evaluates multiple candidate step sizes using a predefined set (Q = [1, 2, 2.5, 5, 10]) and selects the best based on a scoring function that balances simplicity, coverage, and density.
Example :
MaxNLocator:
[0, 20, 40, 60, 80, 100]
WilkinsonLocator:
[0, 25, 50, 75, 100]