Skip to content

Comments

Fix: Multi-line axis/tick labels#678

Open
brenocq wants to merge 1 commit intomasterfrom
fix/multi-line-labels
Open

Fix: Multi-line axis/tick labels#678
brenocq wants to merge 1 commit intomasterfrom
fix/multi-line-labels

Conversation

@brenocq
Copy link
Collaborator

@brenocq brenocq commented Feb 16, 2026

Fixes #630

Summary

Fixes incorrect axis padding calculation when tick labels or axis labels contain
multiple lines (using \n).

Problem

When using custom formatters that output multi-line tick labels, the axis padding
calculation doesn't account for the actual height of the labels, causing:

  • Plot titles to overlap with axis labels
  • Axis labels to extend outside the axis area
  • Incorrect spacing between subplots

Root cause: X-axis padding was calculated before X-axis ticks were generated,
so axis.Ticker.MaxSize.y was 0 or a default value. Additionally, axis label
height was assumed to be single-line.

Solution

  1. Recalculate X-axis padding after tick generation - Added a second call to
    PadAndDatumAxesX() after ticks are generated (when actual tick label sizes are
    available), while preserving the title padding
  2. Use CalcTextSize() for axis labels - Properly measure axis label height
    instead of assuming single-line (T + P), allowing multi-line axis labels to work
    correctly

Before

Image

Here's after the fix to take into account the tick label height and X axis label height

Image

@brenocq brenocq self-assigned this Feb 16, 2026
@brenocq brenocq added type:fix Something isn't working prio:medium Medium priority status:review The task is under review labels Feb 16, 2026
@brenocq brenocq changed the title fix: multi-line axis/tick labels Fix: Multi-line axis/tick labels Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:medium Medium priority status:review The task is under review type:fix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two-line axis values extend beyond the SubPlot boundary.

1 participant