Skip to content

Add WilkinsonLocator using Extended Wilkinson Algorithm#31393

Open
Aryan-Gore wants to merge 1 commit intomatplotlib:mainfrom
Aryan-Gore:wilkinson-clean
Open

Add WilkinsonLocator using Extended Wilkinson Algorithm#31393
Aryan-Gore wants to merge 1 commit intomatplotlib:mainfrom
Aryan-Gore:wilkinson-clean

Conversation

@Aryan-Gore
Copy link

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]

@oscargus
Copy link
Member

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 git rebase -i main, remove the redundant commits and push to the old PR.)

@Aryan-Gore
Copy link
Author

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 git rebase -i main, remove the redundant commits and push to the old PR.)

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 .

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.

2 participants