Balance geom label whitespace #5663
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR to the RC aims to fix an internally discussed issue.
Briefly, in the RC we always add the descent height at the bottom of the label, which is not always visually pleasing. In this PR, descent is also added to the top and descent is ignored when the label padding exceeds the descent.
I think a visual demonstration will perhaps explain it best.
In the current ggplot 3.4.4, the issue was that the descent was not applied at all, leaving some characters, like 'j' partially hanging outside the textbox with 0 padding.
Created on 2024-01-25 with reprex v2.1.0
The current development version mitigates this issue by always adding the descent to the bottom of the label (by means of #5030).
There are two issues with this:
vjust
is awkward, having the descent poke out beneath the anchor point whenvjust = 0
.Same code with current RC branch:
This PR applies the descent only if the padding is insufficient, and simultaneously at the top and the bottom of the label.
This fixes the balance issue mentioned before. While at it, I also fixed the
vjust
issue.Same code with this PR: