Skip to content

Conversation

@cvanelteren
Copy link
Collaborator

@cvanelteren cvanelteren commented Dec 31, 2025

This PR avoids title overlap with a‑b‑c labels when both are placed in the same location. During draw, it measures the rendered widths of the two texts and, if needed, scales the title font down to fit within the available horizontal space for left, right, and centered alignments. The change is localized to _update_title_position, so it only affects shared‑location titles and leaves other title behavior unchanged.

@cvanelteren cvanelteren marked this pull request as draft December 31, 2025 10:14
@cvanelteren
Copy link
Collaborator Author

There is no real issue that closes this, more an issue I run into sometimes where the titles will overlap with the labels.

@cvanelteren cvanelteren marked this pull request as ready for review December 31, 2025 10:19
@cvanelteren cvanelteren requested a review from beckermr December 31, 2025 10:19
@cvanelteren cvanelteren marked this pull request as draft December 31, 2025 10:41
@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 91.12903% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/axes/base.py 81.66% 3 Missing and 8 partials ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren cvanelteren marked this pull request as ready for review January 1, 2026 05:32
@cvanelteren cvanelteren added this to the v1.71.0 milestone Jan 6, 2026
Comment on lines 3049 to 3051
width_inches = self._get_size_inches()[0]
pad = (abcpad / 72) / width_inches
abc_pad = (self._abc_pad / 72) / width_inches
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please

  1. leave a comment on the difference between abcpad, sel._abc_pad, pad, and abc_pad.

  2. Rename the variables to better match their usage and meaning.

I get the unit conversion, but I don't understand what each variable means, what they are used for, and where they come from.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Renamed local variables to better reflect their purpose:
- abcpad -> abc_title_sep_pts (abc-title separation in points)
- pad -> abc_title_sep (abc-title separation in axes coords)
- abc_pad -> abc_offset (user's horizontal offset in axes coords)

Added comprehensive inline comments explaining:
- The difference between abc-title separation (spacing when co-located)
  and abc offset (user's horizontal shift via abcpad parameter)
- Unit conversions from points to axes coordinates
- Source and purpose of each variable

Updated documentation:
- Enhanced abcpad parameter docstring to clarify it's a horizontal offset
- Added inline comments to instance variables at initialization

This addresses co-author feedback requesting clarification of the
relationship between abcpad, self._abc_pad, pad, and abc_pad variables.

No API changes - all modifications are internal refactoring only.
@cvanelteren cvanelteren merged commit 1510047 into main Jan 7, 2026
25 checks passed
@cvanelteren cvanelteren deleted the fix-title-abc branch January 7, 2026 22:38
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.

3 participants