Skip to content

Add WilkinsonLocator based on Extended Wilkinson Algorithm#31391

Closed
Aryan-Gore wants to merge 10 commits intomatplotlib:mainfrom
Aryan-Gore:wilkinson-locator-Aryan
Closed

Add WilkinsonLocator based on Extended Wilkinson Algorithm#31391
Aryan-Gore wants to merge 10 commits intomatplotlib:mainfrom
Aryan-Gore:wilkinson-locator-Aryan

Conversation

@Aryan-Gore
Copy link

PR summary

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]

Seed can be manually set for path.sketch by modifying the value of rcParams path.sketch_seed or by passing a seed value to xkcd or Artist.set_sketch . Seed will also have a rolling(auto incrementing) behaviour.

Co-Authored-By: Oscar Gustafsson <8114497+oscargus@users.noreply.github.com>
Co-Authored-By: eudoxos <1029876+eudoxos@users.noreply.github.com>

Co-authored-by: AryanSheka
@oscargus
Copy link
Member

It seems like the majority of your PR consists of changes related to sketch seed. Please remove those.

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?

@oscargus
Copy link
Member

Replaced by #31393

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