New spacing
and margins
root theme elements
#5631
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 aims to fix #5622.
Briefly, this PR adds
spacing
andmargins
theme elements that act as the 'root' element for other spacing and margin settings in the plot. For example, thelegend.box.spacing
inherits fromspacing
andlegend.margin
inherits frommargins
. The default looks of themes are preserved.As a detail, functions like
theme_gray()
already sort of applied the same logic as this PR applies via thehalf_line
variable. This PR implicitly ensures that thehalf_line
variable also gets stored in thespacing
element.Regretfully, I could not find an elegant way to have text elements inherit from the
margins
element, so these remain as-is.I also made the
legend.ticks.length
inherit fromlegend.key.size
. Currentlylegend.ticks.lenght
was set by default to"npc"
units, but that might have no clear meaning depending on the type of legend. Inheriting from the key size preserves the look but is more clear what the length will be without knowing the internal detail that the 'npc' units relate to the dimensions of a particular cell in the gtable.Some examples.
Created on 2024-01-05 with reprex v2.0.2