Skip to content

ENH: Ignore empty text for tightbbox#31285

Merged
QuLogic merged 1 commit intomatplotlib:text-overhaulfrom
scottshambaugh:text_tightbbox_empty
Mar 12, 2026
Merged

ENH: Ignore empty text for tightbbox#31285
QuLogic merged 1 commit intomatplotlib:text-overhaulfrom
scottshambaugh:text_tightbbox_empty

Conversation

@scottshambaugh
Copy link
Contributor

@scottshambaugh scottshambaugh commented Mar 11, 2026

PR summary

This ignores empty or hidden text for tightbbox, dedicating more space to the plot in tight & constrained layouts. Some of the constrained layout images are larger for reasons I don't fully understand, but it's probably something to do with those invisible text bboxes being used to calculate internal padding.

Targeting the text-overhaul branch.

@QuLogic when I regenerate baseline images, it adds a much larger diff than expected. How are you handling those on this branch?

AI Disclosure

None.

PR checklist

@scottshambaugh scottshambaugh changed the title Ignore empty text for tightbbox ENH: Ignore empty text for tightbbox Mar 11, 2026
@QuLogic
Copy link
Member

QuLogic commented Mar 11, 2026

@QuLogic when I regenerate baseline images, it adds a much larger diff than expected. How are you handling those on this branch?

You have to start with the images from the text-overhaul-figures branch in #30161, either starting from that branch directly and rebasing a commit with just the changes you need, or just copying them in and tracking what you want to properly add to the commit.

@scottshambaugh scottshambaugh marked this pull request as ready for review March 11, 2026 22:44
@scottshambaugh
Copy link
Contributor Author

Makes sense, that worked. Images here updated - let me know if I should be retargeting those to text-overhaul-figures instead

@QuLogic
Copy link
Member

QuLogic commented Mar 11, 2026

No need, I'll take care of updating that branch when this is approved.

@QuLogic QuLogic added this to the v3.11.0 milestone Mar 12, 2026
@github-project-automation github-project-automation bot moved this to Waiting for other PR in Font and text overhaul Mar 12, 2026
@QuLogic QuLogic moved this from Waiting for other PR to Ready for Review in Font and text overhaul Mar 12, 2026
@QuLogic QuLogic force-pushed the text_tightbbox_empty branch from 5725832 to 8095b72 Compare March 12, 2026 20:07
@QuLogic QuLogic force-pushed the text_tightbbox_empty branch from 8095b72 to d772043 Compare March 12, 2026 20:09
@QuLogic
Copy link
Member

QuLogic commented Mar 12, 2026

Sorry, accidentally pushed the wrong commit to strip out the test images from here. Should be good again, and ready for merging, as I've put the new images on the text-overhaul-figures branch.

@QuLogic QuLogic merged commit 364c027 into matplotlib:text-overhaul Mar 12, 2026
45 of 59 checks passed
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in Font and text overhaul Mar 12, 2026
@jklymak
Copy link
Member

jklymak commented Mar 12, 2026

I think your diagnosis was correct - remove_text just sets the strings to empty I think and their existence meant they still had anchor points that were causing the tightbbox to include them.

wavebyrd pushed a commit to wavebyrd/matplotlib that referenced this pull request Mar 13, 2026
…x_empty

ENH: Ignore empty text for tightbbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants