Long legend title justification #5570
Merged
+155
−28
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 #1903.
To recap, when it comes to legend* title justification there are two situations to keep in mind:
* also applies to colourbars, coloursteps and bin legend
Currently, the title's justification applies only in situation 1. In other words, title justification is currently meaningless in situation 2.
This PR extends meaning to title justification in situation 2, by aligning the keys/labels with the title. Previously, these were hardcoded to be left-aligned with oneanother (or top-aligned if title position was left/right). The title justification settings now have the following simplified meaning:
hjust = 0
the legend title and keys should be left-aligned.hjust = 1
the legend title and keys should be right-aligned.vjust = 0
the legend title and keys should be bottom-aligned.vjust = 1
the legend title and keys should be top-aligned.The approach is the same as demonstrated by Claus in #1903 (comment), but integrated into the legend code. I decided against Thomas' comment to separate this into yet another theme setting, because situation 2 had no meaning and could be given meaning.
To demonstrate, the reprex from #1903 can now right-align the title with the keys/labels:
Created on 2023-12-07 with reprex v2.0.2