✨ Justification for legend keys #6279
Open
+205
−15
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 aims to fix #3669.
It introduces a new theme element
legend.key.justification
to control the placement of legend keys when there is more space available than needed to display the key. This condition can be met by having text that is larger than the key or when keys have unequal sizes like inlinewidth
orsize
legends. I arrived at the conclusion that this should be a justification setting because it was unclear where exactly to place the key if it were just a boolean setting. Moreover, this nicely allows for justification settings in both the horizontal and vertical direction (see snapshot test).Reprex from the issue, note that the keys in the the second row of the first legend no longer stretch:
Created on 2025-01-10 with reprex v2.1.1