Skip to content

FIX: include axis labels in get_tightbbox when not for_layout_only#31932

Open
rcomer wants to merge 1 commit into
matplotlib:mainfrom
rcomer:fix/axes3d-tightbbox-labels
Open

FIX: include axis labels in get_tightbbox when not for_layout_only#31932
rcomer wants to merge 1 commit into
matplotlib:mainfrom
rcomer:fix/axes3d-tightbbox-labels

Conversation

@rcomer

@rcomer rcomer commented Jun 20, 2026

Copy link
Copy Markdown
Member

PR summary

Fixes #28117 and fixes #31568

This is the rebased branch from #31571, with some modifications for the 3D case and an added fix for the standard axes case. Since 5c75807 we have not been passing for_layout_only=False from the axes get_tightbbox down to the axis get_tightbbox. This PR makes sure that we do by explicitly calling axis.get_tightbbox() for that case, without the keyword in case we have hold of a third party axis that does not support it.

An alternative solution is to modify the _get_tightbbox_for_layout_only helper function, which I tried at #28117 (comment). I'd be happy to switch to that - I don't have an opinion on which is better.

The code from #31568 now gives
3d_tight

The code from #28117 (comment) now gives
test

Note there is also #31573, but I prefer the solution from #31571 because it leaves the responsibility for the axis labels with the relevant axis.

AI Disclosure

No AI used by me.

PR checklist

@rcomer

rcomer commented Jun 20, 2026

Copy link
Copy Markdown
Member Author

See #31931 for the py312 Ubuntu failure.

@rcomer rcomer added the PR: bugfix Pull requests that fix identified bugs label Jun 20, 2026
@rcomer rcomer closed this Jun 23, 2026
@rcomer rcomer reopened this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: bugfix Pull requests that fix identified bugs topic: axes topic: mplot3d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: savefig(bbox_inches='tight') clips axis labels on 3D axes [Bug]: The zlabel on 3D axes will be cut when using '%matplotlib inline' in Jupyter

2 participants