choose_minor_divider
- pysmithchart.utils.choose_minor_divider(p0, p1, candidates, threshold, map_func, *, max_divisions=None, prefer_aligned=True, prefer_nice=True, tol=1e-09)[source]
Choose a minor-grid divider that yields visually acceptable spacing.
This is the shared algorithm used by both fancy and non-fancy minor grids.
The divider is selected from candidates by testing each candidate divider d via the minimum adjacent distance in mapped (Moebius) space over the entire interval [p0, p1]. Candidates that do not meet threshold are rejected.
- Among acceptable candidates, the selection prefers:
aligned endpoints (both endpoints are integer multiples of the implied step),
“nice” decimal steps (mantissas in {1, 2, 2.5, 5} × 10^n),
larger divider counts.
- Parameters:
p0 – Interval endpoint
p1 – Interval endpoint, with p1 > p0.
candidates – Iterable of integer candidate division counts (e.g. [1, 2, 3, 4, 5, 10]).
threshold – Minimum acceptable adjacent spacing in mapped space.
map_func – Callable
map_func(p) -> complexmapping a parameter value to a complex coordinate (e.g., Moebius-space point).max_divisions – If provided, ignore candidates greater than this value.
prefer_aligned – If True, prefer candidates where both endpoints are close to integer multiples of the implied step.
prefer_nice – If True, prefer “nice” decimal steps (mantissas in {1, 2, 2.5, 5}×10^n).
tol – Tolerance used for alignment checks.
- Returns:
int – Chosen division count. Falls back to the smallest candidate if none satisfy the threshold.