Skip to content

Slightly inconsistent y-axis title gap (depending on tick label widths) #596

@grantmcdermott

Description

@grantmcdermott

Something I spotted while working on #595. The issue is subtle and only really occurs when switching between single character y labels and 2+ character labels. Note the slightly bigger gap between the y title and labels in the top plot compared to the bottom plot.

library(tinyplot) # current dev version
tinytheme('bw', grid = FALSE)
plt(1, yaxb = 1, xaxb = 1, xlab = "Xx", ylab = "Yy", type = "n")

plt(10, yaxb = 10, xaxb = 1, xlab = "Xx", ylab = "Yy", type = "n")

tinytheme()

Created on 2026-05-29 with reprex v2.1.1

Again, it's subtle but the gap should be constant (exactly equal to gap.lab) regardless of label width. The good news is that Claude and I have identified the culprit, which actually stems from three issues:

  1. The whtsbp threshold used a cex-dependent value (min(1, 0.5 * cex_axis)) that created a discontinuity at the narrow/wide label boundary
  2. The bump was clamped to ≥ 0, so narrow-label plots never adjusted their margin or title position
  3. A negative ymgp_shift (from cex_axis < 1) pushed the title away from labels

Fix incoming as part of #595.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions