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
spacingandmarginstheme elements that act as the 'root' element for other spacing and margin settings in the plot. For example, thelegend.box.spacinginherits fromspacingandlegend.margininherits 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_linevariable. This PR implicitly ensures that thehalf_linevariable also gets stored in thespacingelement.Regretfully, I could not find an elegant way to have text elements inherit from the
marginselement, so these remain as-is.I also made the
legend.ticks.lengthinherit fromlegend.key.size. Currentlylegend.ticks.lenghtwas 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