Skip to content

plot: center axis label glyph boxes in canvas coordinates - #806

Open
mikamikasuki wants to merge 1 commit into
gonum:masterfrom
mikamikasuki:fix/centered-axis-label-bounds
Open

mikamikasuki wants to merge 1 commit into
gonum:masterfrom
mikamikasuki:fix/centered-axis-label-bounds

Conversation

@mikamikasuki

Copy link
Copy Markdown

Centered axis labels are drawn at the canvas midpoint, but their glyph boxes used the normalized arithmetic midpoint of the data range. On logarithmic axes this can add padding on the wrong side and clip a label that fits the canvas. Very large finite linear ranges can also overflow that midpoint calculation.

Use normalized coordinate 0.5 for both centered label glyph boxes. Tests compare bounds with the position requested by axis drawing and exercise horizontal and vertical label containment through Plot.Draw.

Validation: the root package and all non-plotter packages pass race tests on Go 1.25 and 1.26. Configured copyright, formatting, imports, Staticcheck 2025.1, and vet checks pass. Plotter image comparisons fail on this macOS host; matching base runs reproduce the same failures, and the seven affected image outputs are byte-identical before and after the patch. Tests use -trimpath for the recorder's expected source paths.

Prepared with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant